Conversation
|
Warning Review limit reached
Next review available in: 9 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughChangesFile growth sendfile handling
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Comment |
|
Updated 12:12 AM PT - Jul 11th, 2026
❌ @robobun, your commit fb0ecfe has 2 failures in
🧪 To try this PR locally: bunx bun-pr 33657That installs a local version of the PR into your bun-33657 --bun |
|
CI for fb0ecfe (build 71814):
Review threads resolved. Ready for review. |
090e7a6 to
0e63f34
Compare
0e63f34 to
2de114f
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/js/bun/http/bun-serve-file.test.ts`:
- Line 1142: Update the “Bun.file response after the file grew on disk” suite to
use describe.concurrent instead of describe, since each test’s run() invocation
has isolated tempDir and server state.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 33caa0e2-2a05-4dfe-a26c-ce86899a5a4e
📒 Files selected for processing (2)
src/runtime/server/RequestContext.rstest/js/bun/http/bun-serve-file.test.ts
…ze is stale When a handler reads .size (or awaits .exists()) on a Bun.file and the underlying file then grows before the Response is sent, do_sendfile compared the blob's cached size against the fresh fstat and concluded the blob was a sub-range. That produced an unsolicited 206 Partial Content with Content-Range: bytes 0-(stale-1)/* and a body truncated to the stale length, for a request that sent no Range header. The whole-file check now compares the blob's size against the size cached on the store by resolve_size (file.max_size) rather than the fresh stat, so a stale cached size is recognised as a whole-file blob. Whole-file blobs are served at the fresh stat'd length with status 200, and incoming Range headers are resolved against that length.
2de114f to
fb0ecfe
Compare
|
Closing as part of a cleanup of stale pull requests. This PR has had no new commits since 2026-07-11, it conflicts with main, and its last CI run failed. This is not a judgment on the fix itself. If the problem still reproduces on a current build, reopen this PR after a rebase or open a new one against main. |
Repro
On 1.4.0 and
main:Adding any init header (
new Response(f, { headers: { "x-a": "b" } })) flips the status to 200 but the body is still truncated to 1000.RFC 9110 §15.3.7: a 206 is only ever the answer to a Range request. An unsolicited 206 poisons caches, and the silent truncation is data loss.
Cause
do_sendfilereopens the file and takes a fresh fstat, then decides whether the blob is a sub-range by comparing the blob's cachedsizeagainst that freshstat_size. When.size/.exists()cached the size at 1000 and the file has since grown to 5000,size != stat_sizeand the blob is treated as a slice:needs_content_rangeis set,sendfile.remainis capped at the stale 1000, andrender_metadatapromotes the headerless path to 206.The
is_whole_filecheck for native Range handling had the same defect: it compared againststat_size, so a stale-cached whole-file blob was excluded and an incoming Range header was ignored.Fix
A whole-file blob's
sizeis either the unset sentinel or the valueresolve_sizecached on the store (file.max_size); a.slice()writessizedirectly and does not touch the store cache.is_whole_filenow compares againstfile.max_size(captured before the store borrow ends) instead of the freshstat_size, and is computed once up front. A whole-file blob then sendsstat_sizebytes (never the stale cache), never setsneeds_content_range, and is eligible for native Range handling, which resolves the client's Range against the fresh size.Shrink (file smaller than the cached size) already behaved correctly and is unchanged.
.slice()behavior is unchanged except for one state that is bit-identical to an unsliced blob:f.slice(0, f.size)after.sizewas read (offset 0,size == store.max_size). That is served as the whole fresh file instead of an unsolicited 206 at the stale length; the Blob struct has no field that distinguishes it from an unsliced blob.Not addressed here (pre-existing, same bug class): when the path did not exist at
.size/.exists()time and is created afterward,resolve_sizefalls through tosize = 0withstore.max_sizestillMAX_SIZE, and that state is indistinguishable from.slice(0, 0)on a never-stat'd file. Fixing it without regressing the explicit empty slice needs a dedicated sliced bit onBlob, which touches the#[repr(C)]layout shared with C++ and the structured-clone format. Follow-up.Verification
New
describe("Bun.file response after the file grew on disk")intest/js/bun/http/bun-serve-file.test.ts:.size/await .exists()/ nothing, with and without init headers: 200,Content-Length: 5000, noContent-Range, full bodyRange: bytes=0-1999resolves against the fresh size: 206,bytes 0-1999/5000Range: bytes=2000-2999(past the stale cached size) is satisfiable against the fresh size6 of the 8 fail without the fix, all pass with it. The rest of
bun-serve-file.test.tsand theserve.test.tsContent-Range/Bun.file suites are unchanged.Related
#32794 removes the
needs_content_rangesetter entirely for the unsolicited-206 side of this, but still capssendfile.remainat the staleoriginal_sizeso the body remains truncated. This PR is narrower and fixes both the 206 and the truncation without changing the documented slice behavior #32794 is pending a maintainer call on.no test proof · iteration 5 · Platform-specific test(s) that do not run on this machine. Deferring to CI, which covers all platforms: test/js/bun/http/bun-serve-file.test.ts