Skip to content

fix(ports): stop joining an undefined resourcesPath on a non-Electron host - #16370

Merged
nwparker merged 1 commit into
nwparker/orcad-item1-honestyfrom
nwparker/orcad-item2-declare-gaps
Aug 25, 2026
Merged

nwparker merged 1 commit into
nwparker/orcad-item1-honestyfrom
nwparker/orcad-item2-declare-gaps

Conversation

@nwparker

@nwparker nwparker commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​26 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​26
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​8 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​6

Plan item 2's remainder, stacked on #16369. A live crash path in the shipped orcad bundle.

The bug

resolveWorkerEntryPath branched on isPackaged alone and joined process.resourcesPath:

if (layout.isPackaged) {
  return join(layout.resourcesPath, 'app.asar', 'out', 'main', WORKER_ENTRY_FILENAME)
}

orcad reports isPackaged true — correctly; it is a production build, and ~15 consumers read it that way to gate HTTPS-only skill downloads and the real CLI name. But process.resourcesPath is Electron-only and undefined under plain Node, and the worker entry name is in the orcad bundle.

So the packaged branch threw:

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined

where a clean "worker unavailable" was the honest outcome. A crash, not a degradation.

Why it hid

The type said resourcesPath: string. It is now string | undefined, so the compiler carries the fact rather than a comment asserting it.

A host with no Electron resources tree has no asar to look in, so it falls back to the module directory and lets the caller report a missing worker.

Provenance

Found by the item 1 agent while auditing the same isPackaged defect class that broke the watcher — it flagged this one as worse, because it throws rather than degrades. Correct call.

It also flagged two siblings I am not fixing here: ai-vault/session-scanner-service-entry-path.ts and computer/sidecar-client.ts carry the same !isPackaged gate and are in the bundle, but neither child is shipped in any orcad layout, so correcting their paths only relocates the failure. Those are declare-the-gap material, not path fixes.

Proof

Verified in both directions — reverting the guard reproduces the exact TypeError:

FAIL  resolveWorkerEntryPath on a non-Electron host > does not join an undefined resourcesPath
AssertionError: expected [Function] to not throw an error but
'TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined' was thrown

Ratchet 0, build-orcad green (incl. the plain-Node smoke-load), smoke:orcad-terminal passes, typecheck and lint clean.

Trade-offs

Zero user-facing. The desktop path is unchanged: with a real Electron resources tree, layout.resourcesPath is truthy and the asar branch is taken exactly as before.

… host

`resolveWorkerEntryPath` branched on `isPackaged` alone and joined
`process.resourcesPath`. orcad reports `isPackaged` true — correctly, it is a
production build, and ~15 consumers read it that way to gate HTTPS-only skill
downloads and the real CLI name — but `process.resourcesPath` is Electron-only
and `undefined` under plain Node.

So the packaged branch threw
`TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string`
where a clean "worker unavailable" was the honest outcome. The type said
`resourcesPath: string`, which is how it went unnoticed; it is now
`string | undefined`, so the compiler carries the fact.

A host with no Electron resources tree has no asar to look in, so it falls back
to the module directory and lets the caller report a missing worker.

Found by the item 1 agent while auditing the same `isPackaged` defect class in
the watcher. Verified in both directions: reverting the guard reproduces the
TypeError.
@nwparker
nwparker force-pushed the nwparker/orcad-item2-declare-gaps branch from 6f13689 to 22a5070 Compare August 25, 2026 05:22
@nwparker
nwparker merged commit da7bf40 into nwparker/orcad-item1-honesty Aug 25, 2026
48 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant