Repository navigation
Conversation
…assed as fetch init
`instrumentFetcher` built the outgoing init with an object spread (`{ ...init }`).
When `init` is itself a Request (the common `stub.fetch(url, request)` Workers
idiom), its method, headers and body are prototype getters rather than own
properties, so the spread copied none of them. Behind an instrumented Durable
Object or service binding the call arrived as a bare GET with no headers and no
body, breaking WebSocket upgrades and forwarded POSTs that work without Sentry.
Handle a Request-valued `init` the same way the existing single-Request branch
does: rebuild through the Request constructor (which reads those members by
property access) and layer the tracing headers, which already include the
request's own headers, on top.
Fixes getsentry#26367
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #26367
The problem
instrumentFetcherbuilt the outgoing init with an object spread:Forwarding a request as
stub.fetch(url, request)is a common Workers idiom, soinitis often itself aRequest. ARequest'smethod,headers,bodyand the rest are prototype getters, not own enumerable properties, so the spread copied none of them. Behind an instrumented Durable Object namespace or service binding the call reached the object as a bareGETwith no headers and no body, which broke WebSocket upgrades (Upgrade: websocket) and every forwardedPOST. The same call works without Sentry.The fix
Handle a Request-valued
initthe same way the existinginput instanceof Request && init === undefinedbranch already handles a Request input: rebuild through theRequestconstructor, which readsmethod,headersandbodyby property access, then layer the tracing headers (which already include the request's own headers) on top. Plain-objectinitstill goes through the existing spread path, so no other case changes.Tests
Added two cases to
instrumentFetcher.test.ts: a Request-valuedinitwith a method, headers and body is forwarded intact with tracing headers added, and the same holds (minus tracing) when trace data is empty.