Skip to content

fix(provider-html-local): clamp over-long ranges and serve empty files - #421

Open
rudycelekli wants to merge 1 commit into
hypit-ai:mainfrom
rudycelekli:fix/html-local-range-clamp
Open

rudycelekli wants to merge 1 commit into
hypit-ai:mainfrom
rudycelekli:fix/html-local-range-clamp

Conversation

@rudycelekli

@rudycelekli rudycelekli commented Oct 18, 2026 •

Copy link
Copy Markdown

The local capture server that serves a staged HTML Program and its media to Chrome refuses two requests it should answer:

clip.mp4 (1000 bytes)  Range: bytes=500-1499  -> 416 bytes */1000   (expected 206 bytes 500-999/1000)
empty.webp (0 bytes)   no Range               -> 416 bytes */0      (expected 200, empty body)
  • RFC 9110 §14.1.2 says a range's last position at or past the end of the representation is replaced by the last byte. Only a first position past the end is unsatisfiable. Media elements and other clients send bounded ranges after seeks, and an over-long one was refused instead of served to the end. Studio's own range server already clamps (fix(studio): serve composition material in the ranges a media element asks for #329); this server was not changed.
  • A request without Range was validated as the range 0-(size-1), which is 0--1 for an empty file, so an empty staged asset was answered 416 instead of 200.

A request without Range is now always a complete 200 (an empty file gets Content-Length: 0 and an empty body). A bounded range clamps its last position to the end of the file. bytes=N- and in-range requests are answered as before. A first position at or past the end, and a reversed range, are still 416.

The new packages/provider-html-local/test/server.test.ts starts the server on a temporary directory and checks full, bounded, open-ended, over-long, past-the-end and reversed ranges, plus an empty file. It fails on main and passes with the change.

Checks run:

  • node --import tsx --test packages/provider-html-local/test/server.test.ts
  • node --import tsx --test packages/provider-html-local/test/stage.test.ts packages/provider-html-local/test/frames.test.ts (8 passed)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant