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
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.