mswjs / msw

Industry standard API mocking for JavaScript.
https://mswjs.io
MIT License
16k stars 522 forks source link

feat: treat unhandled exceptions in handlers as 500 error responses #2135

Closed kettanaito closed 6 months ago

kettanaito commented 7 months ago

Todo

kettanaito commented 7 months ago

Need to adjust some tests to reflect the Interceptors change.

kettanaito commented 7 months ago

The problem was that we throw an error in onUnhandledRequest and we intend that error to be forwarded to the process but since it happens within the request listener, it gets treated as an unhandled error and translated to the 500 error response. This hurts observability as it masks the error as an error response.

I've merged https://github.com/mswjs/interceptors/pull/566 to allow us to opt-out from that default behavior and handle our internal errors differently (e.g. by forwarding them to the process).

kettanaito commented 6 months ago

Released: v2.3.0 🎉

This has been released in v2.3.0!

Make sure to always update to the latest version (npm i msw@latest) to get the newest features and bug fixes.


Predictable release automation by @ossjs/release.

jrnail23 commented 6 months ago

While I don't love the breaking change with a minor rev, this is a good change! It actually allowed me to undo a bunch of special casing I introduced into my tests to handle the previously unhandled errors as I'm porting my http stubbing library from nock to msw.