Skip to content
This repository was archived by the owner on Jul 6, 2026. It is now read-only.

fix(dev): repair dev startup and server teardown on Node 24#12

Open
sontek wants to merge 3 commits into
obot-platform:mainfrom
sontek:fix/dev-startup-teardown
Open

fix(dev): repair dev startup and server teardown on Node 24#12
sontek wants to merge 3 commits into
obot-platform:mainfrom
sontek:fix/dev-startup-teardown

Conversation

@sontek

@sontek sontek commented Jun 6, 2026

Copy link
Copy Markdown

Three related fixes to the local dev environment (pnpm dev) on the current Node 24 / Electron 42 toolchain. They are independent commits but share one trigger, so they are grouped here.

Running the Electron main process through tsx crashed on startup: tsx cannot serve Node 24's synchronous require(esm), which the dev update check reaches. Loading the esbuild bundle the build step already produces keeps tsx out of the main process and avoids the crash.

That faster startup then exposed a race where the window loaded before the Vite and Go dev servers were listening, showing a blank window and a burst of failed WebSocket connections. The renderer now waits for the backend and retries the load, timing out and proceeding anyway so a genuinely-down backend still surfaces its error.

Finally, Ctrl-C used to orphan the Go server, which kept holding the API port and broke the next start. The dev server now tears down its whole child process tree on shutdown, including the built binary that air runs in a separate process group.

No production code paths change: the packaged app still loads through its own protocol and starts its own bundled server, both guarded by app.isPackaged.

sontek added 3 commits June 6, 2026 13:15
dev:app ran electron/main.ts through tsx, which crashes under Node 24's
synchronous require(esm): tsx 4.22.4's load hook returns a null source on
that path, and Electron 42 (bundled Node 24) reaches it via the
electron-updater dev update check. Run the esbuild bundle that
build-electron.mjs already produces instead, keeping tsx out of the
Electron main process entirely.
Loading the bundle starts Electron faster than tsx did, which exposed a
startup race: the window loaded the Vite URL before Vite and the Go server
were listening, leaving a blank window and a burst of failed project-events
WebSocket connections.

The renderer load now waits for the dev backend to accept a connection,
then retries the Vite load until it succeeds. Both waits time out and
proceed anyway, so a backend that never comes up still surfaces its error
in the UI instead of hanging forever.
dev:server runs `go run air`, and air runs the built server binary in its
own process group. A process-group kill of `go run` missed that binary, so
on Ctrl-C it orphaned and kept holding the API port, breaking the next
start with "address already in use".

Snapshot the descendant PIDs before signalling (killed processes reparent
and vanish from the tree), signal each by PID, and force-kill any straggler
after a deadline. Also reflect the child's signal-death in the exit code.
@sontek sontek marked this pull request as ready for review June 6, 2026 17:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant