Skip to content

Bun.serve: fix HEAD and 204 response framing - #32800

Merged
Jarred-Sumner merged 8 commits into
mainfrom
farm/d01b7291/serve-head-204-framing
Jun 28, 2026
Merged

Jarred-Sumner merged 8 commits into
mainfrom
farm/d01b7291/serve-head-204-framing

Clarify the noBodyStatus contract and shorten a test comment

5dda2e5
Select commit
Loading
Failed to load commit list.
Claude / Claude Code Review completed Jun 27, 2026 in 27m 43s

Code review found 1 important issue

Found 2 candidates, confirmed 2. See review comments for details.

Details

Severity Count
🔴 Important 1
🟡 Nit 0
🟣 Pre-existing 0
Severity File:Line Issue
🔴 Important src/runtime/server/FileRoute.rs:479-483 FileRoute with status 101: Content-Length suppressed but file body still streamed → keep-alive desync

Annotations

Check failure on line 483 in src/runtime/server/FileRoute.rs

See this annotation in the file changed.

@claude claude / Claude Code Review

FileRoute with status 101: Content-Length suppressed but file body still streamed → keep-alive desync

The same gap exists in `FileRoute` for status 101, which `writeStatus` now also flags as `noBodyStatus` but which is not in this `204 | 205 | 304 | 307 | 308` early-return list. `new Response(Bun.file(p), { status: 101 })` as a static route reaches `write_header_int("content-length", size)` (silently dropped by the new `writeHeader(key, uint64_t)` guard) and then `FileResponseStream::start`, which ships the file bytes via OS sendfile / `HttpResponse::write()` — neither goes through `internalEnd`