Frontmatter
| id | 9547 |
| title | Fix RemoteMethodAccess for Main Thread Addons and Instance-to-Instance ID collision |
| state | Closed |
| labels | bugaiarchitecturecore |
| assignees | tobiu |
| createdAt | Mar 24, 2026, 10:18 PM |
| updatedAt | Mar 24, 2026, 10:19 PM |
| githubUrl | https://github.com/neomjs/neo/issues/9547 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | 9449 |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Mar 24, 2026, 10:19 PM |
Fix RemoteMethodAccess for Main Thread Addons and Instance-to-Instance ID collision
tobiu assigned to @tobiu on Mar 24, 2026, 10:18 PM

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:
- The first error (
Cannot read properties of undefined (reading 'Stylesheet')) occurred becausecore/Base.mjswas checkingif (me.singleton === true)but omitted|| me.isMainThreadAddon === true. Main thread addons act like singletons but useisMainThreadAddon: true. Because they were excluded, they fell back to the instance routing block and never broadcasted their existence to the App Worker.- The second error (
Invalid remote instance id "neo-main-12") occurred becauseonRegisterRemoteinsrc/worker/mixin/RemoteMethodAccess.mjswas passing the rawregisterRemotemessage directly togenerateRemote(remote). This raw message contains a messageidappended bypromiseMessage().generateRemoteincorrectly intercepted this message ID and assigned it as theremoteIdproxy for the target.Implementation Details:
- Restored
me.isMainThreadAddon === trueinsidesrc/core/Base.mjs'sinitRemote()to ensure addons broadcast correctly.- Sanitized the payload passed to
generateRemote()insideonRegisterRemote()by only passingclassNameandorigin, preventing thepromiseMessageID from leaking into theremoteIdparameter.- Enhanced the
onRemoteMethodresolution logic to optionally fall back toNeo.idMapif theInstancemanager 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
Bug Description
In PR #9546, we refactored
RemoteMethodAccessto support declarative remote configs for instance IPC. This introduced two critical regressions:Stylesheet) were no longer broadcastingregisterRemotemessages because the check incore/Base.mjsonly checkedme.singleton === true, failing to account forme.isMainThreadAddon === true. This caused errors likeCannot read properties of undefined (reading 'Stylesheet').registerRemotemessage was received,onRegisterRemotewas passing the entire message payload (which includes a messageidgenerated bypromiseMessage) togenerateRemote. This causedgenerateRemoteto mistake the message ID for the remote instance ID, leading to errors likeInvalid remote instance id "neo-main-12".Proposed Solution
|| me.isMainThreadAddon === trueinsrc/core/Base.mjsinsideinitRemote.generateRemoteinsideonRegisterRemoteinsrc/worker/mixin/RemoteMethodAccess.mjsto prevent the messageidfrom leaking.onRemoteMethodto fallback toNeo.idMapif theNeo.manager.Instanceis not available yet.