Skip to content

Bun.serve: answer a matching If-None-Match on a Bun.file route without opening the file - #43124

Open
Nic-Polumeyv wants to merge 1 commit into
oven-sh:mainfrom
Nic-Polumeyv:file-route-304-without-open
Open

Nic-Polumeyv wants to merge 1 commit into
oven-sh:mainfrom
Nic-Polumeyv:file-route-304-without-open

Conversation

@Nic-Polumeyv

Copy link
Copy Markdown
Contributor

A Bun.file route opens and fstats the file before it evaluates If-None-Match, so its 304 costs more than one returned from a JS handler (found in sveltejs/kit#17123). When the request matches an ETag the route was given, this answers from one stat instead: 47.5 -> 26.8 µs CPU per 304 on a debug build, 200s unchanged, and a missing file still falls through.

@Nic-Polumeyv
Nic-Polumeyv marked this pull request as ready for review September 17, 2026 18:05

@claude claude Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: fcb4b9a4-3408-4f30-91ea-0b9327686aa8

📥 Commits

Reviewing files that changed from the base of the PR and between b52d513 and d82dbb5.

📒 Files selected for processing (2)
  • src/runtime/server/FileRoute.rs
  • test/js/bun/http/bun-serve-file.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


Walkthrough

Changes

File cache validation

Layer / File(s) Summary
Metadata-only 304 path
src/runtime/server/FileRoute.rs
Eligible GET and HEAD requests now validate file metadata before opening the file and return a bodyless 304 response when the conditions match.
Conditional request coverage
test/js/bun/http/bun-serve-file.test.ts
Tests cover matching ETags, unreadable and deleted files, conflicting conditions, and GET and HEAD behavior.

Suggested reviewers: robobun

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to d82db

The metadata-based conditional-file response preserves the stated fallback cases, and no remaining issue requires changes before merge.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description explains the performance change, the affected behavior, and the reported verification results. It does not use the template headings or state the exact test commands, but it provides t…
Title check ✅ Passed The title clearly and concisely describes the main change: returning a matching If-None-Match response for a Bun.file route without opening the file.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

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