LearnNewsExamplesServices
Frontmatter
id9547
titleFix RemoteMethodAccess for Main Thread Addons and Instance-to-Instance ID collision
stateClosed
labels
bugaiarchitecturecore
assigneestobiu
createdAtMar 24, 2026, 10:18 PM
updatedAtMar 24, 2026, 10:19 PM
githubUrlhttps://github.com/neomjs/neo/issues/9547
authortobiu
commentsCount1
parentIssue9449
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtMar 24, 2026, 10:19 PM

Fix RemoteMethodAccess for Main Thread Addons and Instance-to-Instance ID collision

Closed v12.1.0 bugaiarchitecturecore
tobiu
tobiu commented on Mar 24, 2026, 10:18 PM

Bug Description

In PR #9546, we refactored RemoteMethodAccess to support declarative remote configs for instance IPC. This introduced two critical regressions:

  1. Main thread addons (like Stylesheet) were no longer broadcasting registerRemote messages because the check in core/Base.mjs only checked me.singleton === true, failing to account for me.isMainThreadAddon === true. This caused errors like Cannot read properties of undefined (reading 'Stylesheet').
  2. When the registerRemote message was received, onRegisterRemote was passing the entire message payload (which includes a message id generated by promiseMessage) to generateRemote. This caused generateRemote to mistake the message ID for the remote instance ID, leading to errors like Invalid remote instance id "neo-main-12".

Proposed Solution

  1. Restore || me.isMainThreadAddon === true in src/core/Base.mjs inside initRemote.
  2. Pass a sanitized object to generateRemote inside onRegisterRemote in src/worker/mixin/RemoteMethodAccess.mjs to prevent the message id from leaking.
  3. Enhance the ID check in onRemoteMethod to fallback to Neo.idMap if the Neo.manager.Instance is not available yet.
tobiu added the bug label on Mar 24, 2026, 10:18 PM
tobiu added the ai label on Mar 24, 2026, 10:18 PM
tobiu added the architecture label on Mar 24, 2026, 10:18 PM
tobiu added the core label on Mar 24, 2026, 10:18 PM
tobiu referenced in commit b86088c - "fix(core): Resolve RemoteMethodAccess routing for main thread addons and instance IPC ID collisions (#9547)" on Mar 24, 2026, 10:18 PM
tobiu assigned to @tobiu on Mar 24, 2026, 10:18 PM
tobiu
tobiu Mar 24, 2026, 10:19 PM

Input from Gemini 3.1 Pro:

✦ I have successfully resolved the routing issues within RemoteMethodAccess.

Root Cause Analysis:

  1. The first error (Cannot read properties of undefined (reading 'Stylesheet')) occurred because core/Base.mjs was checking if (me.singleton === true) but omitted || me.isMainThreadAddon === true. Main thread addons act like singletons but use isMainThreadAddon: true. Because they were excluded, they fell back to the instance routing block and never broadcasted their existence to the App Worker.
  2. The second error (Invalid remote instance id "neo-main-12") occurred because onRegisterRemote in src/worker/mixin/RemoteMethodAccess.mjs was passing the raw registerRemote message directly to generateRemote(remote). This raw message contains a message id appended by promiseMessage(). generateRemote incorrectly intercepted this message ID and assigned it as the remoteId proxy for the target.

Implementation Details:

  • Restored me.isMainThreadAddon === true inside src/core/Base.mjs's initRemote() to ensure addons broadcast correctly.
  • Sanitized the payload passed to generateRemote() inside onRegisterRemote() by only passing className and origin, preventing the promiseMessage ID from leaking into the remoteId parameter.
  • Enhanced the onRemoteMethod resolution logic to optionally fall back to Neo.idMap if the Instance manager is not yet available, ensuring robustness.

I will close this ticket.

tobiu added parent issue #9449 on Mar 24, 2026, 10:19 PM
tobiu closed this issue on Mar 24, 2026, 10:19 PM