-
Notifications
You must be signed in to change notification settings - Fork 77
fix: Fix for hono issue 4563 - incorrect content-length after following symlink #290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… stat to follow links
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a bug in the static file serving middleware where symbolic links were not handled correctly. The issue was that lstatSync does not follow symlinks, causing it to read metadata from the symlink itself rather than the target file. This resulted in incorrect Content-Length headers and incomplete file responses. The fix changes lstatSync to statSync, which follows symlinks and retrieves the correct file metadata, making the behavior consistent with other runtime adapters like Bun.
- Changed
lstatSynctostatSyncto properly follow symbolic links when serving static files - Updated the import statement to reflect the new function usage
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Thank you 👍 |
|
Please let me know if this looks good or if you’d prefer some adjustments, I'm really happy to help! :) |
yusukebe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
|
Nice fix! Thank you very much for your contribution! |
This PR fixes honojs/hono#4563
The issue was, lstat does not follow symlinks, so it read the wrong content length and an incomplete file was returned to the client. Changed lstat to stat, and the behavior is as expected (matches what we get when we run the server with bun adapters instead of node-server)