fix: prevent upstream body-presence rejection on proxied XRPC requests#146
Draft
webpro wants to merge 2 commits intoascorbic:mainfrom
Draft
fix: prevent upstream body-presence rejection on proxied XRPC requests#146webpro wants to merge 2 commits intoascorbic:mainfrom
webpro wants to merge 2 commits intoascorbic:mainfrom
Conversation
Cloudflare Workers subrequests to CF-proxied origins (like api.bsky.app) intermittently inject transfer-encoding: chunked, causing the upstream XRPC server to reject GET requests with 'A request body was provided when none was expected' (bluesky-social/atproto#3267). Changes: - Switch from header blocklist to allowlist, preventing CF-internal headers (transfer-encoding, cf-*, etc.) from leaking into subrequests - Use explicit Request constructor for GET/HEAD to produce a cleaner wire format - Retry up to 3x on the specific body-presence 400 error as a safety net for CF intermittent behavior Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Author
Owner
|
I wonder if this flag could help. I'm unsure if it applies to proxied requests or just worker-to-worker |
commit: |
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.

Summary
Fixes intermittent
"A request body was provided when none was expected"errors when using the PDS on Cloudflare Workers. This affects both desktop (bsky.app) and mobile clients.Root cause: Cloudflare Workers subrequests to CF-proxied origins (like
api.bsky.app) intermittently injecttransfer-encoding: chunkedon the wire, even for GET requests with no body and clean headers. The upstream XRPC server (@atproto/xrpc-server) detects this header and rejects the request (bluesky-social/atproto#3267).This is not controllable via the
Headersobject passed tofetch()— CF's internal routing adds it after the Worker'sfetch()call. Confirmed by sending a completely emptynew Headers()GET from a Worker toapi.bsky.appand still receiving the 400.Changes to
handleXrpcProxy:accept,accept-encoding,accept-language,atproto-accept-labelers,if-none-match,if-modified-since,user-agent(+content-type/content-lengthfor POST). This prevents CF-internal headers (cf-*,transfer-encoding,te,x-forwarded-*, etc.) from leaking into subrequests.Requestconstructor for GET/HEAD —fetch(new Request(url, { method, headers }))produces a cleaner wire format thanfetch(url, { method, headers })in the CF Workers runtime.Test plan
pds.webpro.blue)