Skip to content

Fix #64, add range header forwarding - #147

Open
fangpenlin wants to merge 5 commits into
cloudflare:mainfrom
sunday-robotics:range-header-forwarding
Open

Fix #64, add range header forwarding#147
fangpenlin wants to merge 5 commits into
cloudflare:mainfrom
sunday-robotics:range-header-forwarding

Conversation

@fangpenlin

Copy link
Copy Markdown

Originally the worker doesn't handle Range header, as a result, if a big layer connection drops, and the client try to resume the progress sending Range header, it will fail. The issue can be found #64

This PR implements the Range header forwarding to solve the problem

cursoragent and others added 3 commits August 13, 2026 00:34
Clients may resume or probe a blob with the RFC 9110 suffix form
'Range: bytes=-<n>', asking for the last n bytes. That form was parsed
as malformed and silently downgraded to a full 200 response.

Model BlobRangeRequest as a union of an offset range and a suffix range,
resolve suffixes against the object size in the R2 backend, and forward
them upstream verbatim. A suffix longer than the object is satisfied by
the whole object, while a zero-length suffix is unsatisfiable.

Co-authored-by: Fang-Pen Lin <hello@fangpenlin.com>
When a blob is not cached in R2, the blob GET handler falls back to the
configured upstream registries. Any error from an upstream was treated
as a miss, so an unsatisfiable range reached the client as a synthetic
404 BLOB_UNKNOWN, telling it the blob does not exist and discarding the
Content-Range that carries the real object size.

Report a 416 from an upstream directly, matching how a 416 from the
primary R2 store is already handled. Other failures keep falling through
to the next registry.

Co-authored-by: Fang-Pen Lin <hello@fangpenlin.com>
pnpm format:check was failing on this branch because the getLayer
signature was wrapped across multiple lines where prettier wants it on
one.

Co-authored-by: Fang-Pen Lin <hello@fangpenlin.com>
@fangpenlin
fangpenlin marked this pull request as ready for review August 13, 2026 00:53
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