Skip to content

fix: prevent response disposal race condition in E2E test#582

Merged
Shironex merged 1 commit intoAutoMaker-Org:v0.13.0rcfrom
stefandevo:fix/e2e-response-disposal-race
Jan 19, 2026
Merged

fix: prevent response disposal race condition in E2E test#582
Shironex merged 1 commit intoAutoMaker-Org:v0.13.0rcfrom
stefandevo:fix/e2e-response-disposal-race

Conversation

@stefandevo
Copy link
Copy Markdown
Collaborator

@stefandevo stefandevo commented Jan 18, 2026

Summary

  • Fix flaky E2E test open-existing-project.spec.ts that intermittently fails with "Response has been disposed" error
  • Replace response.body() with response.json() to properly handle the response lifecycle

Root Cause

The previous approach created a promise from response.body() but by the time it was awaited, the response had already been disposed by Playwright. Using response.json() directly handles this correctly.

Test plan

  • Matches pattern used in other test files (feature-manual-review-flow.spec.ts, new-project-creation.spec.ts)
  • E2E tests pass in CI

Summary by CodeRabbit

  • Tests
    • Enhanced test resilience for project opening scenarios by improving error handling and API route interception reliability.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 18, 2026

📝 Walkthrough

Walkthrough

The test for opening an existing project has been enhanced to be resilient against fetch failures and disposed responses. Route interception now uses guarded fetch operations with error handling, and response handling has been improved to use JSON parsing with fallback logic, while ensuring test project data is properly injected into the settings payload.

Changes

Cohort / File(s) Summary
API Route Interception Resilience
apps/ui/tests/projects/open-existing-project.spec.ts
Enhanced route.fetch() with error guards to continue on failure; replaced manual response property extraction with await response.json(); added JSON parsing error handling; modified route.fulfill() to pass response object with modified JSON payload; added logic to nullify currentProjectId and inject test project into settings.projects while preventing duplicates

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A test that once would fail and fret,
Now bounces back without regret!
With guarded fetches, robust and true,
The settings dance in JSON's hue—
Error-proof, the project shines through! 🌟

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately and specifically describes the main fix: preventing a response disposal race condition in the E2E test, which matches the core change in the changeset.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @stefandevo, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a persistent flakiness issue in an end-to-end test by refining how network responses are handled within Playwright. The core change involves adopting a more robust method for parsing JSON responses, which prevents a race condition where the response object could be disposed before its content was fully processed. This enhancement significantly improves the stability and reliability of the test suite.

Highlights

  • Flaky E2E Test Fix: Addresses an intermittent 'Response has been disposed' error in the open-existing-project.spec.ts E2E test, which was causing flakiness in the test suite.
  • Playwright API Usage Improvement: Replaces the manual consumption of response.body() and subsequent JSON parsing with Playwright's response.json() method. This change correctly handles the response lifecycle, preventing race conditions where the response might be disposed prematurely.
  • Simplified Route Fulfillment: Streamlines the route.fulfill call by passing the original response object along with the modified json data. This allows Playwright to automatically infer and apply the original status and headers, reducing boilerplate.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively addresses a race condition in the open-existing-project.spec.ts E2E test that was causing intermittent failures. The switch from response.body() to response.json() is the correct and idiomatic approach in Playwright to handle JSON responses, preventing the "Response has been disposed" error by properly managing the response lifecycle. Additionally, simplifying the route.fulfill call to use { response, json } is a great improvement, making the code cleaner and less error-prone by forwarding the original response's status and headers while only overriding the body. The changes are solid and improve both the reliability and maintainability of the test suite.

@stefandevo stefandevo marked this pull request as draft January 18, 2026 15:01
Wrap route.fetch() and response.json() in try/catch blocks to handle
cases where the response is disposed before it can be accessed. Falls
back to route.continue() to let the original request proceed normally.

This fixes the intermittent "Response has been disposed" error in
open-existing-project.spec.ts that occurs due to timing issues in CI.
@stefandevo stefandevo force-pushed the fix/e2e-response-disposal-race branch from 35d2550 to eb30ef7 Compare January 18, 2026 15:14
@stefandevo stefandevo marked this pull request as ready for review January 18, 2026 15:18
@Shironex Shironex merged commit e73c92b into AutoMaker-Org:v0.13.0rc Jan 19, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants