app: production renderer never boots — node builtins survive as ESM imports the file:// loader cannot resolve #233
Labels
No labels
agent-blocked
agent-working
autopilot
bug
deferred
deploy-pending
enhancement
landing-pr
model-haiku
model-opus
model-sonnet
needs-design
needs-info
needs-triage
no-triage
out-of-scope
priority
ready-for-agent
ready-for-human
ready-for-session
rehearsal-183
snapshot-pending
standing-drive
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Matou/idss#233
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Parent
Found during #183 Phase A (A1, first real launch of the production shell). Reported during the same QA thread as #230–#232.
What happened
The operator app's production shell opened to a blank window on its very first real launch. The renderer's built bundles keep the node builtins (
node:child_process,node:fs/promises,node:path) as ESM imports; loaded fromfile://, Chromium's module loader cannot resolve thenode:scheme (ERR_UNKNOWN_URL_SCHEME) and the production entry never executes. Node integration provides CJSrequireto the renderer, not the ESM loader — the build's stated assumption ("resolved at runtime by the node-integrated renderer") does not hold for module-script imports.The production renderer has never been bootable — the boot seam test runs under vitest in Node, where
node:ESM imports resolve fine, so it structurally cannot catch this. This is drift on the real-composition ticket's promise (#191): the packaged app's assets were built but never loaded in the shell.What I expected
The production shell boots the real composition (
data-build="production"on the root) from the built assets, packaged or unpackaged.Steps to reproduce
ERR_UNKNOWN_URL_SCHEMEfor the node builtin imports and a failed dynamic import of the production entry.Additional context
require, withsyntheticNamedExports. External list shrinks toelectronalone. Renderer rebuilt cleanly; all 44 app test files (386 tests) and the typecheck pass. This ticket is for landing that fix (or an equivalent, e.g. the established electron-renderer plugin approach) properly.node:/bare-builtin ESM imports survive in the built renderer chunks, or a minimal real-shell boot smoke, so the packaged path cannot silently regress again.Triage
Category: bug · State: ready-for-agent
Verification: confirmed by inspection —
app/vite.config.tssetsexternal: ['electron', ...builtinModules, ...builtinModules.map(m => 'node:'+m)]on the renderer build, andapp/src/lib/stdioBridge.ts/app/src/entry/channel.ts(both reachable from the renderer entry) importnode:child_process,node:fs/promises,node:path. Those survive the renderer build as realnode:ESM imports, which resolve fine under Vite's dev server and under vitest (Node) but not under Chromium'sfile://module loader — matching the reportedERR_UNKNOWN_URL_SCHEME. Root cause confirmed in code; not yet fixed anywhere in the repo.Agent Brief
Category: bug
Summary: The packaged operator app's production renderer never boots — built chunks keep
node:builtins as ESM imports, which Chromium'sfile://loader cannot resolve.Current behavior:
The renderer's Vite build config keeps node builtins external (alongside
electron) so node-builtin imports reachable from the renderer entry (e.g.stdioBridge'snode:child_process,channel.ts'snode:fs/promises/node:path) survive in the built chunks as real ESM imports. That resolves fine under Vite's dev server and under vitest (Node), but when the built bundle is loaded fromfile://in the packaged Electron shell, Chromium's module loader cannot resolve thenode:scheme (ERR_UNKNOWN_URL_SCHEME), and the production entry never executes — the window opens blank. The existing boot seam test runs under vitest in Node, wherenode:ESM imports resolve fine, so it structurally cannot catch this.Desired behavior:
The packaged production renderer boots successfully from
file://, with the node-builtin-backed code reachable through Electron's node-integratedrequirebridge rather than surviving as unresolved ESM imports in the browser-loaded module graph. A durable guard exists so this class of failure can't silently regress: either a post-build assertion that no bare/node:builtin ESM imports survive in the built renderer chunks, or a minimal real-shell boot smoke test that runs outside vitest/Node.Key interfaces:
externallist for node builtins is the root cause. An approach like compiling each node-builtin import through a build-only bridge resolved via the renderer'srequire(withsyntheticNamedExports), or an established electron-renderer Vite plugin that does the same, resolves it while keepingelectronitself external.Acceptance criteria:
ERR_UNKNOWN_URL_SCHEMEor a blank window.Out of scope:
Note: the reporter mentions a local, uncommitted fix already applied on their machine (a build-only node-builtin bridge). That fix is not present in the repo — treat it as unavailable and implement a fix independently (the approach it describes, or an equivalent plugin-based one, is a reasonable starting point, not a constraint).
Fixed in
b09e951(onorigin/main).Root cause: the renderer's Vite build kept node builtins in the
externallist, sonode:child_process(stdioBridge),node:fs/promises+node:path(channel.ts) survived the renderer build as realnode:ESM imports. Chromium'sfile://module loader cannot resolve thenode:scheme (ERR_UNKNOWN_URL_SCHEME) — the production entry never ran and the window opened blank. Node integration hands the renderer CJSrequire, not the ESM loader.Fix: a build-only Vite plugin (
app/vite-plugin-electron-builtins.ts) compiles each node-builtin import to a module resolving it through the renderer's runtimerequire, with RollupsyntheticNamedExportsso{ spawn }/{ join }named imports keep working. The rendererexternallist shrinks toelectronalone (which the renderer never imports). The Electron main/preload (CJS) build is unchanged. Verified: the builtdistchunks now carryrequire("node:child_process")/node:fs/promises/node:pathand zero survivingnode:ESM imports.Durable guard:
app/tests/unit/rendererBuild.test.tsruns the real renderer build in-memory (write: false) and asserts no node builtin survives as an external import (and that the builtins are bridged viarequire). It fails when the fix is reverted, and is distinct from the go-gated Node boot seam test — which resolvesnode:fine under Node and so structurally cannot see the Chromium-loader failure. A real-shell boot smoke was the other option, but the swarm/CI never downloads the Electron binary (pnpm-workspace.yamldenies its postinstall), so the build-output assertion is the CI-viable guard.Checks: 402 app tests pass (the go-gated
boot.test.tsneedsgoon PATH vianix develop— unrelated to this change);vue-tsctypecheck clean; eslint + prettier clean. Out of scope: packaging/installer (#230/#231), the Quasar app-vite layer (ADR 0108).git worktree repairkilled run 1649's sibling worker #239