File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,8 +11,20 @@ import {
1111import { Path , isPath } from './utils/matching/matchRequestUrl'
1212import { WebSocketClientManager } from './ws/WebSocketClientManager'
1313
14+ function isBroadcastChannelWithUnref (
15+ channel : BroadcastChannel ,
16+ ) : channel is BroadcastChannel & NodeJS . RefCounted {
17+ return typeof Reflect . get ( channel , 'unref' ) !== 'undefined'
18+ }
19+
1420const wsBroadcastChannel = new BroadcastChannel ( 'msw:ws-client-manager' )
1521
22+ if ( isBroadcastChannelWithUnref ( wsBroadcastChannel ) ) {
23+ // Allows the Node.js thread to exit if it is the only active handle in the event system.
24+ // https://nodejs.org/api/worker_threads.html#broadcastchannelunref
25+ wsBroadcastChannel . unref ( )
26+ }
27+
1628export type WebSocketLink = {
1729 /**
1830 * A set of all WebSocket clients connected
You can’t perform that action at this time.
0 commit comments