Repository navigation
fix(routing): preserve intentional native Worker 404s - #778
Merged
Merged
Conversation
cpojer
marked this pull request as ready for review
November 11, 2026 00:47
cpojer
previously approved these changes
Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #775
A route's GET or HEAD 404 could become a 200 when a static file existed at the same path. Keep explicit 404s and let genuine route misses fall back to assets after middleware runs.
Miss tracking follows response clones and
pipeThrough()stream transforms, so middleware such as Hono'scompress()can transform a genuine miss without disabling asset fallback. Independently created middleware and route 404s still keep their status and body.Workerd regression coverage includes GET and HEAD, rewrites, header edits, both branches of a response clone, chained transforms, compression, and intentional replacement 404s. The compression regression fails on the previous code.
Verification: 16,614 tests passed in the full local suite; all 33 package typechecks, package/playground builds, formatting, and lint passed.
Direct prototype calls, such as
Response.prototype.clone.call(c.res)orReadableStream.prototype.pipeThrough.call(c.res.body, transform), bypass the per-instance tracking. In that case a genuine miss can remain a 404 even when a file exists.