Skip to content

Commit 2f6e494

Browse files
committed
Fix deprecated destination warning for registerRemote messages
In SharedWorker environments, sending messages to 'main' is deprecated due to ambiguity (multiple connected windows). However, `registerRemote` calls originate from `core.Base` (often singletons) which generally target the "Main Thread Realm" rather than a specific window. These registration messages are intercepted by `worker.Base` and replayed to all connected Main Thread ports. Therefore, using 'main' as the destination acts as a broadcast signal in this specific context. We now suppress the deprecation warning for `action: 'registerRemote'` to treat it as a valid system-wide broadcast. Resolves #8366
1 parent 618983d commit 2f6e494

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/worker/Base.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ class Worker extends Base {
331331
* @protected
332332
*/
333333
sendMessage(dest, opts, transfer) {
334-
if (dest === 'main' && this.isSharedWorker) {
334+
if (dest === 'main' && this.isSharedWorker && opts.action !== 'registerRemote') {
335335
console.warn('sendMessage destination "main" is deprecated. Use a windowId instead.', opts)
336336
}
337337

0 commit comments

Comments
 (0)