pnpm dev boots a blank window — vite dev server externalizes the renderer's node builtins (#233's bridge is build-only) #345

Closed
opened 2026-08-09 02:19:19 +00:00 by ben · 1 comment
Owner

Symptom. pnpm dev (the documented dev flow: vite dev server on :5173 + OURCLOUD_DEV_SERVER_URL) opens an empty white window. The renderer page loads (kit CSS present) but the composition never mounts.

Evidence. Renderer pageerror, reproduced 2026-08-08 driving the dev app under Playwright:

Module "node:child_process" has been externalized for browser compatibility.
Cannot access "node:child_process.spawn" in client code.

Root cause. The composition spawns the helper in the renderer over node:child_process (stdioBridge, ADR 0108's node-integrated renderer). Issue #233 fixed exactly this for the built renderer with vite-plugin-electron-builtins.ts (electronRendererBuiltins()), which compiles each builtin import to a runtime require. But that plugin is apply: 'build' — under vite dev/serve, vite's own browser-external shim takes over and throws on first access, so the dev-served renderer can never spawn the helper. (The plugin's header claims builtins "resolve under Vite's dev server" — true for vitest's Node environment, not for a served Chromium page.)

Fix sketch. Let the bridge apply in serve mode too (drop apply: 'build' and make resolveId/load cover the dev server's __vite-browser-external path), or an equivalent serve-mode alias. Acceptance: pnpm dev:renderer + pnpm dev boots to Welcome with the helper spawned, and the #233 guard test still passes for the built renderer.

Workaround used meanwhile (works today): build the renderer and serve dist/ statically on the same port — pnpm build:renderer && python3 -m http.server 5173 --directory dist — then launch dev electron as usual (OURCLOUD_DEV_SERVER_URL=http://localhost:5173, OURCLOUD_DEV_HELPER_BIN=$PWD/.dev/helper-dev).

Found during the S12 design-verify arc (merge df66d03).

**Symptom.** `pnpm dev` (the documented dev flow: vite dev server on :5173 + `OURCLOUD_DEV_SERVER_URL`) opens an empty white window. The renderer page loads (kit CSS present) but the composition never mounts. **Evidence.** Renderer pageerror, reproduced 2026-08-08 driving the dev app under Playwright: ``` Module "node:child_process" has been externalized for browser compatibility. Cannot access "node:child_process.spawn" in client code. ``` **Root cause.** The composition spawns the helper in the renderer over `node:child_process` (stdioBridge, ADR 0108's node-integrated renderer). Issue #233 fixed exactly this for the *built* renderer with `vite-plugin-electron-builtins.ts` (`electronRendererBuiltins()`), which compiles each builtin import to a runtime `require`. But that plugin is `apply: 'build'` — under `vite dev`/serve, vite's own browser-external shim takes over and throws on first access, so the dev-served renderer can never spawn the helper. (The plugin's header claims builtins "resolve under Vite's dev server" — true for vitest's Node environment, not for a served Chromium page.) **Fix sketch.** Let the bridge apply in serve mode too (drop `apply: 'build'` and make `resolveId`/`load` cover the dev server's `__vite-browser-external` path), or an equivalent serve-mode alias. Acceptance: `pnpm dev:renderer` + `pnpm dev` boots to Welcome with the helper spawned, and the #233 guard test still passes for the built renderer. **Workaround used meanwhile** (works today): build the renderer and serve `dist/` statically on the same port — `pnpm build:renderer && python3 -m http.server 5173 --directory dist` — then launch dev electron as usual (`OURCLOUD_DEV_SERVER_URL=http://localhost:5173`, `OURCLOUD_DEV_HELPER_BIN=$PWD/.dev/helper-dev`). Found during the S12 design-verify arc (merge `df66d03`).
Author
Owner

Fixed in a466a49 (on origin/main).

Root cause confirmed: electronRendererBuiltins() (#233) was apply: 'build', so under vite dev/serve vite's browser-external shim resolved node:child_process to a Proxy that throws on first access — the dev-served renderer never mounted (blank window).

Fix: drop apply: 'build' so the bridge applies in both serve and build. Its enforce: 'pre' resolveId already runs before vite's core resolver, so it now intercepts every builtin before the shim can claim it in serve mode too — the same require-bridge the packaged build uses. Corrected the header's false claim that builtins "resolve under Vite's dev server".

Guard: new app/tests/unit/rendererDevBoot.test.ts drives the REAL vite dev server's plugin container and asserts each composition builtin (node:child_process/node:fs/promises/node:path/node:process) resolves to the require bridge, never vite's browser-external module (red before the fix, green after). The #233 built-renderer guard (rendererBuild.test.ts) still passes. Full app vitest run green but for the pre-existing go-on-PATH boot suite (spawnSync go ENOENT).

Fixed in a466a49 (on origin/main). **Root cause confirmed:** `electronRendererBuiltins()` (#233) was `apply: 'build'`, so under `vite dev`/serve vite's browser-external shim resolved `node:child_process` to a Proxy that throws on first access — the dev-served renderer never mounted (blank window). **Fix:** drop `apply: 'build'` so the bridge applies in both serve and build. Its `enforce: 'pre'` `resolveId` already runs before vite's core resolver, so it now intercepts every builtin before the shim can claim it in serve mode too — the same `require`-bridge the packaged build uses. Corrected the header's false claim that builtins "resolve under Vite's dev server". **Guard:** new `app/tests/unit/rendererDevBoot.test.ts` drives the REAL vite dev server's plugin container and asserts each composition builtin (`node:child_process`/`node:fs/promises`/`node:path`/`node:process`) resolves to the require bridge, never vite's browser-external module (red before the fix, green after). The #233 built-renderer guard (`rendererBuild.test.ts`) still passes. Full app `vitest run` green but for the pre-existing `go`-on-PATH boot suite (`spawnSync go ENOENT`).
ben closed this issue 2026-08-09 03:19:02 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#345
No description provided.