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: catch uncaught errors in express middleware so they can be passed onwards to the express error handler #913

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

larrysingh
Copy link

@larrysingh larrysingh commented Jan 31, 2025

Summary

Currently the withLogto middleware does not have a try catch block which sometimes leads to uncaught errors and middleware limbo with the request hanging. This PR fixes it by wrapping all the middleware logic in a try/catch block to ensure errors are caught appropriately and they are passed onwards to the next middleware which can be a custom error handler, etc. depending on the user and application.

Testing

I made the changes locally and tried it with my application and the hanging issues were resolved as the error was now able to be caught and handled.

Checklist

  • .changeset - Not sure
  • unit tests N/A
  • integration tests N/A
  • necessary TSDoc comments - Done

Sorry, something went wrong.

…d onwards to the express error handler
@larrysingh larrysingh marked this pull request as draft February 5, 2025 07:36
@larrysingh larrysingh marked this pull request as ready for review February 5, 2025 07:36
@larrysingh
Copy link
Author

@xiaoyijun

@wangsijie
Copy link
Contributor

What about an onError parameter?

@larrysingh
Copy link
Author

What about an onError parameter?

Can you give me an example of that?

@wangsijie
Copy link
Contributor

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

Successfully merging this pull request may close these issues.

None yet

2 participants