Skip to content

fix: preserve the real fs error (ENAMETOOLONG etc.) instead of a generic 404 - #30

Merged
otnc merged 2 commits into
mainfrom
fix/static-url-too-long
Sep 11, 2026
Merged

otnc merged 2 commits into
mainfrom
fix/static-url-too-long

Conversation

@otnc

@otnc otnc commented Sep 11, 2026

Copy link
Copy Markdown
Owner

Summary

`statFile()` swallowed every `stat()` failure into a bare `null`, so `locate()` always reported a hardcoded 'Not Found'/ENOENT regardless of what actually went wrong. An overlong path fails with ENAMETOOLONG, not ENOENT -- Express's own `send` package wraps whatever the real fs error is into a 404 (`createError(404, err)`), keeping its original message and code, rather than replacing it with a generic one.

`statFile()` now only swallows ENOENT/ENOTDIR (genuinely "nothing here", where `locate()` falls back to the next index/extension candidate); anything else propagates, and `send.ts` wraps it into a `SendError(404)` that keeps the real message/code.

Test plan

  • `node test/express-suite/run.js` -- 1108→1109 passing / 8→7 failing (v5), baseline updated
  • `node test/express-suite/run.js --v4` -- 1147→1148 passing / 51→50 failing (v4, the same fix helps both since it's shared code), baseline updated
  • `pnpm run typecheck`
  • `pnpm run ci` (biome)
  • `pnpm run test` (vitest) -- 234 passing

Note

Per your instructions, this PR is not merged -- ready for your review.

…ric 404

statFile() swallowed every stat() failure into a bare null, so
locate() always reported a hardcoded 'Not Found'/ENOENT regardless of
what actually went wrong. An overlong path (root + a huge relative
segment) fails with ENAMETOOLONG, not ENOENT -- Express's own `send`
wraps whatever the real fs error is into a 404 (createError(404, err)),
keeping its original message and code, rather than replacing it with
a generic one.

statFile() now only swallows ENOENT/ENOTDIR (genuinely "nothing here",
where locate() falls back to the next index/extension candidate);
anything else propagates, and send.ts wraps it into a SendError(404)
that keeps the real message/code.

Express suite: 1108/8 -> 1109/7 (v5), 1147/51 -> 1148/50 (v4, the same
fix helps both since it's shared code).
Resolves the conflict from #31 merging first (both touched
README.md's status line and the express-suite baseline). Numbers
recomputed by rerunning both suites fresh against the combined
source.
@otnc
otnc merged commit d00169c into main Sep 11, 2026
5 checks passed
@otnc
otnc deleted the fix/static-url-too-long branch September 11, 2026 17:25
otnc added a commit that referenced this pull request Sep 11, 2026
Resolves the conflict from #30 and #33 merging first (both touched
README.md's status line and/or the express-suite baseline). Numbers
recomputed by rerunning both suites fresh against the combined
source.
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