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
feat: add "unhandledException" life-cycle event #1199
feat: add "unhandledException" life-cycle event #1199
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit c29ffaa:
|
@@ -50,6 +53,12 @@ beforeAll(async () => { | |||
listener(`[request:unhandled] ${req.method} ${req.url.href} ${req.id}`) | |||
}) | |||
|
|||
server.events.on('request:unhandledException', (req, handler, error) => { |
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.
I don't like the way I've modeled these tests in the past. Instead of invoking a listener in this callback function's body, I should've passed the listener as the callback itself. This would allow us to assert all arguments passed along a particular event.
server.events.on('foo', listener)
expect(listener).toHaveBeenCalledWith([mockedRequest, handler, error])
Let's refactor this after this feature 👍
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.
I am on vacation until 25.04. Will refactor it afterwards 👍
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.
Hey, @MartinJaskulla! Thank you for your work on this, it looks superb!
I had only one substantial comment about the order of arguments in the listener. I'd like to hear your opinion on that.
Thank you for your support! Learning a lot 🥳 And yes, errors as the first argument make sense! |
Hey, @MartinJaskulla. I've force-pushed to your feature branch because we've reverted a significant chunk of one change, which made rebasing utterly impossible. I've tried to replicate your changes, so it should be okay now! |
Welcome to the contributors, @MartinJaskulla! 🎉 |
Released: v0.40.0 🎉This has been released in v0.40.0! Make sure to always update to the latest version ( Predictable release automation by @ossjs/release. |
Users can now react to errors thrown in their RequestHandlers. Before this PR all errors were silently converted into a 500 response (only in the browser). Now users can subscribe to a new event: