Frontmatter
| id | 8496 |
| title | ServiceWorker missing hasWorker() method causes initRemote failure |
| state | Closed |
| labels | bugaicore |
| assignees | tobiu |
| createdAt | Jan 10, 2026, 12:17 PM |
| updatedAt | Jan 10, 2026, 12:19 PM |
| githubUrl | https://github.com/neomjs/neo/issues/8496 |
| author | tobiu |
| commentsCount | 1 |
| parentIssue | null |
| subIssues | [] |
| subIssuesCompleted | 0 |
| subIssuesTotal | 0 |
| blockedBy | [] |
| blocking | [] |
| closedAt | Jan 10, 2026, 12:19 PM |
ServiceWorker missing hasWorker() method causes initRemote failure
tobiu assigned to @tobiu on Jan 10, 2026, 12:17 PM

tobiu
Jan 10, 2026, 12:19 PM
Input from tobiu:
◆ Implemented
hasWorker(name)insrc/worker/ServiceBase.mjs.This method is required by
Neo.core.Base.promiseRemotes()to check if a target worker (destination) is available before sending a message.Implementation Details:
hasWorker(name)returnstrueif:
- The destination is 'app' (the main channel).
- A specific message port exists for the destination.
- A fallback client (
lastClient) is available.This fix ensures that
initRemote()calls within the Service Worker context no longer throwTypeError: origin.hasWorker is not a function.
tobiu closed this issue on Jan 10, 2026, 12:19 PM
The Service Worker fails to initialize remote methods because it lacks the
hasWorker()method, which is required byNeo.core.Base.promiseRemotes().The Error:
Base.mjs:892 Uncaught (in promise) TypeError: origin.hasWorker is not a function at Base.mjs:892:28 at Array.forEach (<anonymous>) at Base.promiseRemotes (Base.mjs:888:32) at ServiceWorker.initRemote (Base.mjs:648:24) at ServiceWorker.initRemote (ServiceBase.mjs:172:19) at ServiceWorker.onConnect (ServiceBase.mjs:203:14) at ServiceWorker.onRegisterNeoConfig (ServiceBase.mjs:297:14) at ServiceWorker.onMessage (ServiceBase.mjs:272:39)Root Cause:
Neo.core.Base.promiseRemotes()checksorigin.hasWorker(worker)before sending a message. In the context of a Service Worker,originis theServiceWorkerinstance itself (which extendsServiceBase). However,ServiceBasedoes not implementhasWorker(), unlikeNeo.worker.BaseandNeo.worker.Manager.Fix: Implement
hasWorker(name)insrc/worker/ServiceBase.mjs. Since the Service Worker communicates viathis.sendMessage, which checkschannelPortsorlastClient, the implementation should check if a valid destination exists.For the Service Worker, a "worker" (destination) is available if: