Skip to content

fix(chromium): throw explicit error for evicted non-refetchable response bodies - #42966

Closed
Hardik K (hardikkaurani) wants to merge 2 commits into
microsoft:mainfrom
hardikkaurani:fix/42862-empty-response-body
Closed

Hardik K (hardikkaurani) wants to merge 2 commits into
microsoft:mainfrom
hardikkaurani:fix/42862-empty-response-body

Conversation

@hardikkaurani

Copy link
Copy Markdown

Summary

Fixes #42862.

When a response body is evicted from the CDP cache and it is unsafe to refetch (e.g. it is a \ etch\ GET), Chromium's network manager would silently return an empty 0-byte buffer (\Buffer.from('')). This breaks explicit
esponse.body()\ calls when the page itself already consumed the response (e.g. via .blob()), as developers received 0 bytes without any clear indication of why.

As discussed in #42862, silently failing and returning 0 bytes is incorrect. Re-fetching a \ etch\ GET is also unsafe since it produces server side-effects (e.g. invalidating single-use tokens, as noted in PR #42863).

This PR throws a clear, explicit Error (\Response body is unavailable for evicted resources) instead of returning an empty buffer when a re-fetch is disallowed.

Testing

  • Added a regression test in \page-network-response.spec.ts\ that asserts an explicit error is thrown for \�rowserName === 'chromium'.

Copilot AI lite review requested due to automatic review settings September 28, 2026 13:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@hardikkaurani

Copy link
Copy Markdown
Author

Yury Semikhatsky (@yury-s) The requested changes for #42862 are in place, including the regression coverage for evicted non-refetchable response bodies. When you have a chance, could you please take another look at the latest revision? Thanks!

@dgozman

Copy link
Copy Markdown
Collaborator

This is a breaking change, we don't want this. Thank you for the PR!

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.

[Regression 1.62.1 → 1.63.0]: page Response.body() returns empty after in-page fetch().blob() already consumed it

3 participants