Repository navigation
Conversation
c10c3c3 to
c2e7db2
Compare
jasnell
left a comment
There was a problem hiding this comment.
Not entirely convinced this needs to be gated but don't feel strongly about it.
c2e7db2 to
56aa00f
Compare
|
Dropped the gate. Could you please take a quick look again before I merge? |
The Fetch spec gives a response an empty status message unless
something sets it: ResponseInit.statusText defaults to "", and
"initialize a response" copies it as-is. Only the scheme fetch
steps set one, to `OK` for data: and about:blank URLs and to `OK`
or `Partial Content` for blob: URLs. workerd instead derived the
RFC 9110 reason phrase from the status code, so
`new Response(null, { status: 404 }).statusText` was "Not Found"
rather than "", and likewise for Response.json() and
Response.redirect().
An unset statusText is now "". A Response initialized from another
Response, through the constructor or Response.json(), copies its
status message exactly. Responses returned by fetch() keep the
reason phrase the server sent, even when it matches the status
code's default. data: URL fetches now set "OK" explicitly, which
is the value they already reported. workerd does not fetch blob:
or about: URLs.
The HTTP reason phrase sent for a Response returned to a client is
unchanged: an unset status message still sends the status code's
conventional phrase, so HTTP clients see no difference even though
the JS-visible statusText is empty. Error messages that include a
response's status, such as those thrown by Fetcher's put() and
get() helpers, use the same conventional phrase.
Compatibility: this changes behaviour for all Workers, on every
compatibility date, with no compatibility flag. For example,
`new Response(null, { status: 404 }).statusText` becomes "" where
it was "Not Found", and Response.json() and Response.redirect()
results report "" where they reported "OK" or "Found". This
follows James Snell's review, which questioned gating the change.
The statusText expected failures in response-init-001,
response-static-redirect, response-static-json and response-clone
("Check Response's clone with default values, without body") are
removed from both fetch WPT configs. The js-rpc-test and Python
SDK test expectations that relied on the derived phrase are
updated.
Fixes #4973
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
56aa00f to
5176a4e
Compare
|
💬 Approved with comments — The statusText change is correct and the reason phrase sent on the wire is unchanged. Two notes: the ungated behaviour change, whose risk the commit message records as accepted, and a stale test comment. Findings: 1 info · 1 suggestion The decision is advisory: this comment never approves, blocks or requests changes on the pull request. 📋 Code Quality: 💬 1 info · 1 suggestionThe logic is correct and no call site was missed. Two notes: the ungated behaviour change and a stale test comment. Recommendation: 💬 Optional Nits
View full reviewUngated behaviour change ( Every Worker, on every compatibility date, now sees a different
A Worker that logs Code paths checked
Stale test comment ( The comment says "These Workers run without pedantic_wpt, which WPT always enables." That wording comes from the version gated on ✅ All other checks passed🔒 Security: ✅ LGTMNo security concerns. The reason phrase sent on the wire is unchanged. 📖 AGENTS.md: ✅ LGTMNo AGENTS.md updates needed. ⚡ Performance: ✅ LGTMNo hot-path cost: one small string clone or allocation per response. 📝 Documentation: ✅ LGTMNo documentation issues. Reviewed commit: |
Summary
The Fetch spec gives a response an empty status message unless something sets it.
ResponseInit.statusTextdefaults to"", and only the scheme fetch steps set a value:OKfor data:/about:blank, andOK/Partial Contentfor blob:. workerd instead derived the reason phrase from the status code, sonew Response(null, { status: 404 }).statusTextwas"Not Found", and the same went forResponse.json()andResponse.redirect().Now:
statusTextis"".Response.json()) copies its status message exactly.fetch()responses keep the reason phrase the server sent, even when it matches the default.data: URL fetches now set
"OK"explicitly, which is the value they already reported. workerd doesn't fetch blob: or about: URLs.The HTTP reason phrase on the wire is unchanged. An unset status message still sends the conventional phrase (new
getReasonPhrase()), so HTTP clients see no difference. Error messages that include the status, such as Fetcher'sput()/get()helpers, use the same phrase.Fixes #4973
Compatibility
This changes behaviour for all Workers, on every compatibility date, with no compatibility flag. For example,
new Response(null, { status: 404 }).statusTextbecomes""where it was"Not Found", andResponse.json()/Response.redirect()results report""where they reported"OK"/"Found". This follows James Snell's review, which questioned gating the change behindpedantic_wpt.The statusText expected failures in
response-init-001,response-static-redirect,response-static-jsonandresponse-cloneare removed from both fetch WPT configs. Thejs-rpc-testand Python SDK test expectations that relied on the derived phrase are updated.🤖 Generated with Claude Code