fix(cdn): stop stamping range-less GETs as 206 partial responses

env.BUCKET.get(key, { range: request.headers }) makes R2 report a
DEFINED object.range (full span) even when the request carried no Range
header, so every plain GET went out as 206 + Content-Range. Chrome
executes a 206 <script>; Firefox fires onload but refuses to EXECUTE
the script — on hosts with no masking edge cache (staging workers.dev)
the injected editor glue never ran: no [KICAD_STATUS] logs, heap 0MB,
'runtime did not initialize (no FS) in 90s' on every Firefox boot.
Prod's cdn.pcbjam.com zone cache normalizes cached hits to 200, which
is why only staging surfaced it; cold prod objects share the bug.

Pass the range option only when the request actually sent a Range.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PmR6goSk7JC17h7fkgGvHG
This commit is contained in:
Gergő Törcsvári 2026-08-17 12:32:15 +02:00
commit 42479b313c
No known key found for this signature in database
GPG key ID: 8E75F2CDE64E5322

View file

@ -41,9 +41,17 @@ export default {
);
}
const object = await env.BUCKET.get(key, {
range: request.headers,
});
// Only ask R2 for a range when the request actually sent one: passing the
// headers unconditionally makes R2 report a DEFINED object.range (full
// span) even for range-less GETs, which stamped EVERY response 206 +
// Content-Range. Chrome shrugs at a 206 <script>; Firefox fires onload but
// refuses to EXECUTE it, so on hosts with no masking edge cache (staging's
// workers.dev) the editor glue never ran — "runtime did not initialize
// (no FS) in 90s" on every Firefox boot.
const object = await env.BUCKET.get(
key,
request.headers.has("Range") ? { range: request.headers } : {},
);
if (!object) {
return new Response("Not Found", { status: 404, headers: baseHeaders() });
}