Patch playwright-core to resolve _finishedPromise on requestFailed#93802
Merged
Conversation
The client-side `BrowserContext._onRequestFailed` handler in `playwright-core` does not resolve the corresponding `Response._finishedPromise`, while `_onRequestFinished` does. When Chromium fires `Network.loadingFailed` for a request that already received a response — e.g. an RSC response that was delivered to the response buffer but is no longer needed because a soft navigation has already committed — the server-side `_finishedPromise` is resolved correctly (in `chromium/crNetworkManager._onLoadingFailed`), but the client side is never told. Any caller of `response.finished()` on such a response hangs indefinitely, surfacing in tests as a 60s Jest timeout with no clear stack trace. This is the root cause of intermittent timeouts in router-act-using tests. The patch mirrors the resolve step from `_onRequestFinished`: look up the response via the existing async `request.response()` RPC and fire-and-forget `resolve(null)` on its `_finishedPromise`. `catch` is a no-op so a tearing-down context doesn't produce an unhandled rejection. Verified empirically against workflow run https://github.com/vercel/next.js/actions/runs/25760869258, which flake-detected all 40 router-act consumers (each 3 times) with diagnostic logging enabled. One `Network.loadingFailed canceled=true` event fired during the run (the canonical bug scenario: an outer `act` releasing a child `block: true` response that Chrome canceled mid-flight; see https://github.com/vercel/next.js/actions/runs/25760869258/job/75669131568) — pre-patch this would have hung until Jest's 60s test timeout fired, post-patch `response.finished()` resolved in 1ms. Alongside ~4000 normal resolutions, with zero `wait-browser-finished` hangs and zero router-act-related test failures. This is a stop-gap until the router-act rewrite in #90959 lands, which replaces Playwright's `route.fulfill` + `response.finished()` flow with a browser-side `fetch` interception and removes the dependency on this Playwright code path entirely. The patch can be dropped at that point.
playwright-core to resolve _finishedPromise on requestFailed
Contributor
Tests PassedCommit: c70f628 |
lubieowoce
approved these changes
May 13, 2026
Member
|
damn, nice find |
lubieowoce
pushed a commit
that referenced
this pull request
May 13, 2026
Reverts #92199. Depends on #93802, which patches `playwright-core` to fix the root cause: the client-side `Response._finishedPromise` was never resolved on `requestFailed`, causing `response.finished()` to hang indefinitely and surface as opaque 60s Jest timeouts in router-act-using tests. With that patch in place, the cached-navigations tests can be reinstated. This PR's CI is part of the verification path — the previously-flaky tests now run cleanly through the 3× flake-detection job. <!-- NEXT_JS_LLM_PR -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The client-side
BrowserContext._onRequestFailedhandler inplaywright-coredoes not resolve the correspondingResponse._finishedPromise, while_onRequestFinisheddoes. When Chromium firesNetwork.loadingFailedfor a request that already received a response — e.g. an RSC response that was delivered to the response buffer but is no longer needed because a soft navigation has already committed — the server-side_finishedPromiseis resolved correctly (inchromium/crNetworkManager._onLoadingFailed), but the client side is never told. Any caller ofresponse.finished()on such a response hangs indefinitely, surfacing in tests as a 60s Jest timeout with no clear stack trace.This is the root cause of intermittent timeouts in router-act-using tests.
The patch mirrors the resolve step from
_onRequestFinished: look up the response via the existing asyncrequest.response()RPC and fire-and-forgetresolve(null)on its_finishedPromise.catchis a no-op so a tearing-down context doesn't produce an unhandled rejection.Verified empirically against workflow run https://github.com/vercel/next.js/actions/runs/25760869258, which flake-detected all 40 router-act consumers (each 3 times) with diagnostic logging enabled. One
Network.loadingFailed canceled=trueevent fired during the run (the canonical bug scenario: an outeractreleasing a childblock: trueresponse that Chrome canceled mid-flight; see https://github.com/vercel/next.js/actions/runs/25760869258/job/75669131568) — pre-patch this would have hung until Jest's 60s test timeout fired, post-patchresponse.finished()resolved in 1ms. Alongside ~4000 normal resolutions, with zerowait-browser-finishedhangs and zero router-act-related test failures.This is a stop-gap until the router-act rewrite in #90959 lands, which replaces Playwright's
route.fulfill+response.finished()flow with a browser-sidefetchinterception and removes the dependency on this Playwright code path entirely. The patch can be dropped at that point.