Frontmatter
| id | 8339 |
| title | Remote Method Registration Missing for Secondary Windows in SharedWorker |
| state | Closed |
| labels | bugaicore |
| assignees | tobiu |
| createdAt | Jan 5, 2026, 9:03 PM |
| updatedAt | Jan 5, 2026, 9:27 PM |
| githubUrl | https://github.com/neomjs/neo/issues/8339 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Jan 5, 2026, 9:27 PM |
Remote Method Registration Missing for Secondary Windows in SharedWorker
tobiu assigned to @tobiu on Jan 5, 2026, 9:03 PM

tobiu
Jan 5, 2026, 9:27 PM
Input from Gemini 3 Pro:
✦ I have implemented the fix for remote method registration in SharedWorker environments.
Key Changes:
State Persistence (
src/worker/Base.mjs):
- Added
remotesToRegisterarray toNeo.worker.Base.- In
onConnected, the worker now iterates through this array and sendsregisterRemotemessages to the newly connected port. This ensures that every new window receives the necessary proxy definitions.Registration Logic (
src/core/Base.mjs):
- Updated
initRemoteto populateNeo.currentWorker.remotesToRegisterwhen running in a SharedWorker environment.- Refactored the connection logic to be more robust: it now unconditionally registers the remote (if applicable) and then awaits the
connectedevent if the worker is not yet ready, before proceeding topromiseRemotes.Verification:
- Verified that multi-window applications now correctly receive remote method proxies in secondary windows.
- Confirmed that existing Dedicated Worker workflows and tests remain unaffected.
tobiu closed this issue on Jan 5, 2026, 9:27 PM
tobiu cross-referenced by #8497 on Jan 10, 2026, 12:28 PM
Context: In a
useSharedWorkers: trueenvironment, a single worker instance (e.g., App, Data) serves multiple connected browser windows (Main Threads).The Problem: Currently,
Neo.core.Base#initRemote()sends theregisterRemotemessage only once when the singleton is first initialized.initRemotecalled ->registerRemotesent to Window 1. Correct.initRemoteis NOT called again.registerRemotehandshake. It has no proxies for the singleton's remote methods.Impact:
Proposed Solution:
Neo.core.Base#initRemote, iftarget === 'main'and we are in a SharedWorker, store the registration payload (className,methods) in a registry onNeo.currentWorker(e.g.,remoteMethodRegistry).Neo.worker.Base#onConnected(which fires every time a new window connects), iterate through this registry and re-send all storedregisterRemotemessages to the newly connected port only.Scope:
src/core/Base.mjs: UpdateinitRemoteto register payloads.src/worker/Base.mjs: Add registry storage and updateonConnectedto replay them.