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(WebSocket): make MessageEvent cancelable #506

Merged
merged 6 commits into from
Feb 15, 2024
Merged

Conversation

kettanaito
Copy link
Member

"undici": "^6.5.0",
"vitest": "^0.28.5",
"undici": "^6.6.2",
"vitest": "^1.2.2",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating vitest has broke a few tests that were using .toContain() for partial object assertions. The behavior of that matcher seemed to have changed across Vitest releases.

I've changed the tests to use .toMatchObject().

*
* @see https://github.com/nodejs/node/issues/51767
*/
export class CancelableMessageEvent<T = any> extends MessageEvent<T> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something we need to remove in the future.

TL;DR Node's MessageEvent cannot be canceled. Doesn't respect the cancelable attribute and so preventDefault() does nothing. Looks like a bug in Node.js. Reported.

@kettanaito kettanaito merged commit 9e1e18f into main Feb 15, 2024
1 check passed
@kettanaito kettanaito deleted the fix/ws-improvements branch February 15, 2024 13:54
@kettanaito
Copy link
Member Author

Released: v0.26.2 🎉

This has been released in v0.26.2!

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.

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

Successfully merging this pull request may close these issues.

1 participant