mswjs / interceptors

Low-level network interception library.
https://npm.im/@mswjs/interceptors
MIT License
564 stars 127 forks source link

WebSocket: Close event is not cancelable, so its default cannot be prevented #644

Closed kettanaito closed 1 month ago

kettanaito commented 1 month ago

This may call back to the Node's issue where MessageEvent is not cancelable. I can see the same being true for the close event:

https://github.com/mswjs/interceptors/blob/2a06bce76dddaeeeb38fc37f2d3e78fbe458ce23/src/interceptors/WebSocket/WebSocketServerConnection.ts#L349

Checking this always yields false even if event.preventDefault() has been called on the close event on the server object.

We currently do a custom CancelableMessageEvent for message events. We may want to do the same for the close event.

kettanaito commented 1 month ago

Released: v0.35.9 🎉

This has been released in v0.35.9!

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


Predictable release automation by @ossjs/release.