Skip to content

fix(webkit): refresh intercepted request headers after response - #44184

Open
microsoft-playwright-automation[bot] wants to merge 3 commits into
mainfrom
fix-44170-44150774510-1
Open

microsoft-playwright-automation[bot] wants to merge 3 commits into
mainfrom
fix-44170-44150774510-1

Conversation

@microsoft-playwright-automation

Copy link
Copy Markdown
Contributor

WebKit resolves intercepted request headers with provisional values before sending the request. Let actual headers replace those values when they arrive, and clear the client's early header cache when the response arrives.

Extend the existing cookie-header test with an unrelated route and an early header read.

Fixes #44170

Triaged on macOS by the Playwright bot - agent run

@github-actions

This comment has been minimized.

@microsoft-playwright-automation

Copy link
Copy Markdown
Contributor Author

🟢 All four failures are pre-existing

I'm the Playwright bot. I checked the MCP failures at b842764066b6243ad1c5105028dce4c5670bbeed; none is caused by this PR.

Failure evidence

Covers MCP run 44152654090. The request-header changes do not explain these failures: the same tests fail with the same errors without this PR.

Pre-existing flake / infra

  • Chrome crash recovery, mcp/crash.spec.ts:31, :58, :79: “reports the navigation error, then resets and logs the crash”, “lists only one tab”, and “marks non-current crashed tab in the tab list”. All three also fail on this PR's base commit, 765383d755f5e0f99e84ad26fd35537cb8e00898, in main run 44150556774. The first times out waiting for recovery; the other two time out with Not connected, exactly as here.
  • Firefox, mcp/sse.spec.ts:196, “sse transport browser lifecycle (persistent)”: localStorage.a returns undefined instead of "42" after reconnecting. The identical failure occurs on main at b5b158ae5cbc88324885505816221bca5e5f967c in run 43525179063, and on an unrelated PR in run 43976537947. Recent history confirms this is intermittent.

Checked the failures on Linux by the Playwright bot - agent run

Comment thread tests/page/page-network-request.spec.ts Outdated
const cookie = (await response.request().allHeaders())['cookie'];
expect(cookie).toBe('myCookie=myValue; myOtherCookie=myOtherValue');

await page.route('**/never-match', route => route.continue());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is ridiculous, it should not have merged it into this test. I'm udpating the AGENTS.md

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Restored the original cookie test and moved the unrelated-route case into a separate, issue-tagged fetch test. It fails on WebKit without the fix and passes on all three browsers.

return await this._actualHeadersPromise;
}

_setResponse(response: Response) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Since this is a webkit-specific error, I expect webkit-specific fix.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed the client cache reset; only WebKit's response handler now requests replacement of provisional headers, while the shared setter keeps its original default behavior. Header reads during paused interception retain their existing behavior.

@microsoft-playwright-automation

This comment has been minimized.

@microsoft-playwright-automation microsoft-playwright-automation Bot added agent-review-done The Playwright bot run ended and removed agent-review labels Nov 20, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@dgozman Dmitry Gozman (dgozman) left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Let's also update the docs to be clear that allHeaders() are not entirely accurate for intercepted requests.

// "null" means no raw headers available - we'll use provisional headers as raw headers.
setRawRequestHeaders(headers: HeadersArray | null) {
setRawRequestHeaders(headers: HeadersArray | null, force = false) {
if (force && this._rawRequestHeadersPromise.isDone())

@dgozman Dmitry Gozman (dgozman) Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We cannot afford allHeaders() changing the value. Also, client caches the value anyway, so it depends on the timing of the first client call. Let's explore taking cookies from the cookie jar in this "intercepted request" case.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

WebKit now fills missing Cookie headers from the URL-filtered cookie jar before publishing the intercepted request. Removed header replacement; the test checks early reads and unchanged headers after a Set-Cookie response. The docs explain the remaining cookie-policy and credentials-mode limits.

Revised on macOS by the Playwright bot - agent run

@dgozman Dmitry Gozman (dgozman) added agent-review and removed agent-review-done The Playwright bot run ended labels Nov 24, 2026
@microsoft-playwright-automation

This comment has been minimized.

@microsoft-playwright-automation

Copy link
Copy Markdown
Contributor Author

Hi, I'm the Playwright bot. I replaced the header refresh with a WebKit-only cookie lookup before intercepted requests are exposed. The reported headers now stay unchanged after the response. I also documented that intercepted headers may differ from those sent, including WebKit's cookie-policy and credentials-mode limits.

On macOS, the regression fails without the fix and passes on Chromium, Firefox and WebKit. The seven network and routing test files passed: 567 passed, 21 skipped. The final cookie checks passed on all three browsers; build and full lint passed. Linux and Windows were not tested.

Revised on macOS by the Playwright bot - agent run

@microsoft-playwright-automation microsoft-playwright-automation Bot added agent-review-done The Playwright bot run ended and removed agent-review labels Nov 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

23684 passed, 708 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

5257 passed, 644 skipped


Merge workflow run.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-review-done The Playwright bot run ended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: WebKit: request.allHeaders() loses Cookie once any page.route is registered

3 participants