Skip to content

Path parameter not accessible when using app.onError() #1590

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

Closed
justinwride opened this issue Oct 17, 2023 · 3 comments · Fixed by #1593
Closed

Path parameter not accessible when using app.onError() #1590

justinwride opened this issue Oct 17, 2023 · 3 comments · Fixed by #1593
Labels

Comments

@justinwride
Copy link

What version of Hono are you using?

3.8.0

What runtime/platform is your app running on?

Cloudflare Workers

What steps can reproduce the bug?

When using app.onError() within a nested route, the path parameters are not accessible.

c.req.param('assignmentId') does not work when app.onError(err, c) is in the nested route file

index.js
routes/example.js

See this project for example: https://github.com/justinwride/hono-path

What is the expected behavior?

I expect to access the path parameter for the route /assignments/:assignmentId? using c.req.param('assignmentId')

What do you see instead?

Instead, c.req.param('assignmentId') is undefined

Additional information

It works if app.onError() is put in index.js, but not if it is used in routes/example.js.

I have been experimenting with Hono and enjoy the simplicity and speed. I'm the CTO of an ed-tech company and hope to use it more in our tech stack.

@usualoma
Copy link
Member

Hi @justinwride
Thanks for the report. This appears to be a bug caused by #1566 and will be investigated.

@yusukebe
Copy link
Member

Hi @justinwride!

Thank you for reporting with the kind explanation.

This issue has been fixed by @usualoma's implementation and the release v3.8.1 includes it. Please give it a try!

@justinwride
Copy link
Author

Thanks @yusukebe and @usualoma! 💯

The fix was very quick and works perfectly. Hono is awesome!

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

Successfully merging a pull request may close this issue.

3 participants