-
Notifications
You must be signed in to change notification settings - Fork 29
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
Use BroadcastChannel to support sub workers #25
base: main
Are you sure you want to change the base?
Conversation
} | ||
|
||
dispose() { | ||
this.channel.removeEventListener('message', this._handleMessageEvent.bind(this)); |
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.
Not happy with requiring a dispose, but since Broadcast channels are global, they need to be cleaned up (don't go away on Worker shutdown)
An alternative would be to force a new channel name on each Client/Server pair, but that would be hard to reconcile because the Client is created in the worker and doesn't have access to the memory of the Server.
Additionally, the BroadcastChannel only works on the same origin. Would the same origin be used for the extension host as the workers in vscode.dev?
Okay maybe this isn't going to work in the browser. Seems that SharedArrayBuffers can't be passed over BroadcastChannels. They only work over MessagePorts. Perhaps a BroadcastChannel can be used to send a message port to the main thread somehow. Then the MessagePort can be used to send messages the way the code used to work |
Fixes #23
Switch to using a BroadcastChannel to allow sub workers to participate in sync messages too.