Repository navigation
Conversation
…end of the body calculateEffectiveBoundaries() rejected an end past the blob and a negative start, but not a start at or past the end of the blob, so "bytes=256-" on a 256-byte response produced a 206 with an empty body and "Content-Range: bytes 256-255/256". Treat such ranges as unsatisfiable, like the other out-of-range cases.
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 #3607
calculateEffectiveBoundaries()rejected anendpast the end of the blob and a negativestart, but never checked whetherstartitself was past the end. A request such asRange: bytes=256-(orbytes=300-) against a 256-byte cached response therefore produced a206 Partial Contentwith an empty body and an invalidContent-Range: bytes 256-255/256(orbytes 300-255/256; see RFC 9110 §14.4).Per RFC 9110 §14.1.2 / §14.2 (formerly RFC 7233 §2.1) a byte range whose first-pos is not less than the length of the representation is unsatisfiable and should get a
416 Range Not Satisfiable, which is whatcreatePartialResponse()already returns for other unsatisfiable ranges. This change adds astart >= blobSizecheck next to the existing ones, so these requests now go through the samerange-not-satisfiablepath. Ranges that start inside the body (includingbytes=0-, open-ended and suffix ranges) are unchanged.Tests: added a case to
test-calculateEffectiveBoundaries.mjs(start equal to and larger than the blob size throwsrange-not-satisfiable) and a case totest-createPartialResponse.mjs(bytes=256-andbytes=257-return 416). Both fail without the change and pass with it; the other range-requests tests still pass.I don't have Chrome on this machine, so I could not use the browser-based service worker test runner. I ran the
workbox-range-requestsSW tests in Node 24 with mocha against thesw-bundle.jsserved by the repo's test server, in both development and production builds: without the change the two new tests fail (19 passing / 2 failing in development, 17 passing / 2 pending / 2 failing in production), and with it everything passes (21 passing; 19 passing / 2 pending). Please treat CI as authoritative.This change was drafted with Claude Code (claude-opus-5-5); the test results above are from the runs described.