Skip to content

Keep the body of a cloned Request in the WPT harness - #8682

Merged
littledivy merged 1 commit into
mainfrom
littledivy/2026-11-19-fetch-clone-stream-body
Nov 19, 2026
Merged

littledivy merged 1 commit into
mainfrom
littledivy/2026-11-19-fetch-clone-stream-body

Conversation

@littledivy

Copy link
Copy Markdown
Member

request/request-clone-readable-stream-body.any.js failed with both stream implementations, but workerd's Request keeps the body. The WPT harness replaces globalThis.Request with a subclass that resolves relative URLs. Its relativizeRequest() then checks input instanceof Request, which now means the subclass. A Request from clone() is a plain Request, so it failed the check and was treated as a URL. new Request(r.clone()) became a GET to "[object Request]" with no body.

In this patch the check uses the real Request, and the test is enabled for both stream implementations. All //src/wpt/... targets pass, so no other expectations change. //src/wpt:fetch/api@ and //src/wpt:fetch/api-ts@ each passed 100 of 100 runs with --runs_per_test=100.

The WPT harness replaces globalThis.Request with a subclass that
resolves relative URLs, and relativizeRequest() then checks
`input instanceof Request`, which now means the subclass. A Request
from clone() is a plain Request, so it failed the check and was
treated as a URL: new Request(r.clone()) became a GET to
"[object Request]" with no body. That is why
request-clone-readable-stream-body.any.js failed with both stream
implementations, though workerd's Request keeps the body.

In this patch the check uses the real Request, and the test is
enabled for both stream implementations.
@littledivy
littledivy requested review from a team as code owners November 19, 2026 17:18

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Approved — A small, correct fix to the harness's instanceof check, plus the matching changes to test expectations. No findings.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

📋 Code Quality: ✅ LGTM

The instanceof realRequest check accepts both plain Request objects and instances of the harness's subclass, which fixes the cloned-Request path. The expectation changes in api-test.ts and api-test-ts.ts match the fix.


📝 Documentation: ✅ LGTM

No documentation impact.


Reviewed commit: 5cb76fa5

@littledivy
littledivy merged commit f944403 into main Nov 19, 2026
23 checks passed
@littledivy
littledivy deleted the littledivy/2026-11-19-fetch-clone-stream-body branch November 19, 2026 17:56
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