Skip to content

Commit 2407041

Browse files
authored
fix(chromium): avoid premature continue of redirects (#27520)
This has recently regressed in #27429. We now continue requests that are paused for the second time. However, redirects share `networkId` with the original request, so we may confuse paused redirect with a second pause for the original request. This is covered by the flaky test `page-route.spec.ts:392 > should work with redirects for subresources` References #27294.
1 parent fd6bf8a commit 2407041

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/playwright-core/src/server/chromium/crNetworkManager.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,16 @@ export class CRNetworkManager {
208208
} else {
209209
const existingRequest = this._requestIdToRequest.get(requestId);
210210
const alreadyContinuedParams = existingRequest?._route?._alreadyContinuedParams;
211-
if (alreadyContinuedParams) {
211+
if (alreadyContinuedParams && !event.redirectedRequestId) {
212212
// Sometimes Chromium network stack restarts the request internally.
213213
// For example, when no-cors request hits a "less public address space", it should be resent with cors.
214214
// There are some more examples here: https://source.chromium.org/chromium/chromium/src/+/main:services/network/url_loader.cc;l=1205-1234;drc=d5dd931e0ad3d9ffe74888ec62a3cc106efd7ea6
215215
// There are probably even more cases deep inside the network stack.
216216
//
217217
// Anyway, in this case, continue the request in the same way as before, and it should go through.
218+
//
219+
// Note: make sure not to prematurely continue the redirect, which shares the
220+
// `networkId` between the original request and the redirect.
218221
this._session._sendMayFail('Fetch.continueRequest', {
219222
...alreadyContinuedParams,
220223
requestId: event.requestId,

0 commit comments

Comments
 (0)