LearnNewsExamplesServices
Frontmatter
id18767
titleworker.Manager drops falsy replies and resolves rejected ones on main
stateClosed
labels
bugaicore
assigneesneo-opus-ada
createdAtSep 16, 2026, 11:05 AM
updatedAtSep 16, 2026, 11:44 AM
githubUrlhttps://github.com/neomjs/neo/issues/18767
authorneo-opus-ada
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtSep 16, 2026, 11:44 AM

worker.Manager drops falsy replies and resolves rejected ones on main

neo-opus-ada
neo-opus-ada commented on Sep 16, 2026, 11:05 AM

Context

Captured by @neo-opus-grace as a defect-note (2026-09-16): a remote method that returns a falsy value never settles its main-thread promise, so Neo.worker.App.getConfigs for an unknown id hangs. Promoted on triage: an executable probe confirms it, and finds two more defects in the same lines.

Correction (2026-09-16, from the PR's CI): this body first claimed no caller compensates for the envelope shape. That census grepped remote-proxy calls only. Three e2e specs call Neo.worker.Manager.promiseMessage from the page and read the SharedWorker envelope — see The Architectural Reality and AC-5. Their passing on dev is also the real SharedWorker witness for defect 3.

Probe: the child-process harness of test/playwright/unit/vdom/MainRenderQueue.spec.mjs, driving src/worker/Manager.mjs at dev@e197300297 with onWorkerMessage({action: 'reply', destination, replyId, data}) against a registered promise:

destination payload result
'main' undefined, null, false, 0 pending forever, promises[replyId] leaked
'main' {ok: 1} resolved with the payload
'main' Error, envelope reject: true resolved with the Error
Manager.windowId {ok: 2} resolved with the whole envelope {action, destination, replyId, data}

The Problem

The reply branch of Manager#onWorkerMessage settles a promise main holds like this:

if (dest === 'main') {data = data.data}
if (data) {promise[data.reject ? 'reject' : 'resolve'](data); delete me.promises[replyId]}

Reassigning data to the payload breaks three things:

  1. The truthiness gate drops falsy results. Neither resolve nor delete runs.
  2. reject is read from the payload, not from the envelope RemoteMethodAccess#reject builds ({action: 'reply', data, reject: true, replyId}). A main-thread awaiter never sees a rejection.
  3. A reply addressed by window id is never unwrapped. Under SharedWorkers, RemoteMethodAccess#resolve / #reject rewrite a main-origin reply's destination to the window id, and this branch only treats 'main' as main.

The Architectural Reality

  • worker.Base#onMessage already settles its own replies correctly: reject from the envelope, data.data as the value, whatever its truthiness. Main diverged from that rule.
  • The rest of onWorkerMessage already treats dest === 'main' || dest === me.windowId as addressed to this thread (registerAppName, remoteMethod); only the reply branch does not.
  • A promise main holds for a forwarded request (dest is another worker) settles with the envelope, and the forwarding .catch reads err?.data ?? err. That contract stays.
  • Main-thread consumers of these promises (census of promiseMessage( across src/main, src/Main.mjs, src/worker/Manager.mjs, test/playwright, apps, examples):
    • generated remote proxies (RemoteMethodAccess#generateRemote): main.DomAccess ×2 (App.setConfigs, which returns result objects) and Manager#setGlobalConfig ignore the value;
    • Manager#checkServiceWorkerVersion reads swVersion?.version, the payload;
    • three e2e specs read the SharedWorker envelope: core/AppWorkerErrorMirror.spec.mjs (receipt.data.success), core/WorkerErrorMirror.spec.mjs (receipt.data.success, receipt.origin), and core/WorkerErrorGate.spec.mjs, which reads both shapes as (receipt?.data ?? receipt) under the comment "A SharedWorker answers with the message envelope, a dedicated worker with its data".

The Fix — src/worker/Manager.mjs

A promise main holds for itself (dest === 'main' || dest === me.windowId) settles like worker.Base settles its own: reject from the envelope, data.data as the value, entry deleted — whatever the payload's truthiness. A forwarded promise keeps settling with the envelope. The three e2e specs read the payload.

Acceptance Criteria

  • AC-1 A reply addressed to 'main' whose payload is undefined, null, false or 0 resolves with that payload and removes its promise entry (unit).
  • AC-2 A reply addressed to 'main' with reject: true rejects with its payload (unit).
  • AC-3 A reply addressed to Manager.windowId resolves with its payload, not the envelope, and rejects on reject: true (unit).
  • AC-4 A promise held for a forwarded request still settles with the envelope — the existing forwarding arm in MainRenderQueue.spec.mjs stays green.
  • AC-5 AppWorkerErrorMirror, WorkerErrorMirror and WorkerErrorGate read the payload promiseMessage resolves with, and pass in CI's e2e-engine.

Out of Scope

  • Worker-side settlement (worker.Base#onMessage): already correct.
  • Reply routing and port lookup (#12958, #18265): settled elsewhere.

Related

#12958 · #18265 · #8339

Live latest-open sweep: latest 20 open issues at 2026-09-16T09:05:08Z; no equivalent found A2A claim sweep: latest 30 inbox messages, all read-states, at 2026-09-16T09:05Z; only the defect-note this promotes, no claim MC sweep: query_raw_memories on the symptom ("main thread remote method call never resolves when worker returns undefined or null; rejected remote call resolves on main; shared worker reply resolves with the message envelope") + KB ticket query, 6 + 6 results; neighbours #8339 / #18265 (reply routing) and #12958 (worker-side reply port), no prior decision on main-side settlement Own-assignment sweep: 8 open, none on src/worker/Manager.mjs

Origin Session ID: fda7faab-19c5-43a0-b192-003966068172 Retrieval Hint: "worker.Manager onWorkerMessage reply settlement: falsy payload never resolves, envelope reject ignored, windowId-addressed reply resolves with envelope"

tobiu referenced in commit c53229b - "test(e2e): worker error specs read the payload a main-thread reply now resolves with (#18767) on Sep 16, 2026, 11:16 AM
tobiu closed this issue on Sep 16, 2026, 11:44 AM
tobiu referenced in commit f949573 - "fix(worker): the main thread settles every reply it holds, the way workers settle theirs (#18767) (#18768) on Sep 16, 2026, 11:44 AM