Skip to content

fix(routing): preserve intentional native Worker 404s - #778

Merged
cpojer merged 2 commits into
voidzero-dev:mainfrom
dvkam:fix/775-native-worker-404
Nov 11, 2026
Merged

cpojer merged 2 commits into
voidzero-dev:mainfrom
dvkam:fix/775-native-worker-404

Conversation

@dvkam

@dvkam dvkam commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

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's compress() 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) or ReadableStream.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.

@cpojer
cpojer marked this pull request as ready for review November 11, 2026 00:47

@cpojer cpojer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

cpojer
cpojer previously approved these changes Nov 11, 2026
@cpojer
cpojer merged commit f9e6924 into voidzero-dev:main Nov 11, 2026
2 checks passed
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.

An intentional 404 from a route is replaced by a static file at the same path / 路由主动返回的 404 被同路径的静态文件替换

2 participants