Repository navigation
fix: preserve the real fs error (ENAMETOOLONG etc.) instead of a generic 404 - #30
Merged
Merged
Conversation
…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).
5 tasks done
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.
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.
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
Note
Per your instructions, this PR is not merged -- ready for your review.