Skip to content
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

Fix bug of serveStatic of deno adapter #3634

Closed
oussamasf opened this issue Nov 6, 2024 · 3 comments
Closed

Fix bug of serveStatic of deno adapter #3634

oussamasf opened this issue Nov 6, 2024 · 3 comments
Labels

Comments

@oussamasf
Copy link
Contributor

oussamasf commented Nov 6, 2024

What version of Hono are you using?

4.6.9

What runtime/platform is your app running on? (with version if possible)

Deno

What steps can reproduce the bug?

const publicFiles = serveStatic({ root: './public/' })
app.use('/.well-known/*', publicFiles)

when ./public/.well-known/ is an empty folder

What is the expected behavior?

404

What do you see instead?

curl: (18) transfer closed with outstanding read data remaining

Additional information

This is a bug fix from issues #3628

Opening an empty directory with Deno.open returns a ReadableStream, which is not valid for directories. This leads to that behavior and lead also to status code 200 although it supposed to be 404.

To prevent this undesired behavior, I have implemented a guard using Deno.stat to check if the path is a file before attempting to open it.

p.s: the guard added is tested and tests are passed
May I have permission to submit a pull request with this fix?

@EdamAme-x
Copy link
Contributor

I think it's good.

@oussamasf
Copy link
Contributor Author

pr

@yusukebe yusukebe added bug and removed triage labels Nov 7, 2024
@yusukebe
Copy link
Member

This is fixed by #3639. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants