githubnext/chopinPublic

Let's compose rich plans together

Make one Ctrl-C stop the whole dev environment

`vite & server` left orphans. The backgrounded half sits in a different process
group from the one the terminal signals, so stopping what you can see left Vite
and its esbuild child running — holding a port and several hundred megabytes,
and quietly serving the next session from a process nobody was watching. A
session of restarts had accumulated about 1.5 GB of them.

A supervisor now owns both. Each child gets its own process group and is killed
as a group, so nothing beneath it survives, and either one exiting takes the
other down: a half-running environment is worse than a stopped one because it
looks like it is working.

Both are spawned directly rather than through `bun run`, which turns out not to
exit when the thing it started dies. It sits there with no child, so a
supervisor watching it never learns that Vite has gone — which is exactly how
the first version of this failed its own test. Running Vite's entry under Bun
also drops the Node shebang in the `.bin` shim, one less thing that has to be
installed.

Vite now binds 127.0.0.1 explicitly. Bound to `localhost` it took both ::1 and
127.0.0.1, and `strictPort` then failed to notice a second instance because the
two never collided — leaving two dev servers on "the same port" and edits
landing in whichever the OS resolved first.

Verified for all three endings: Ctrl-C, Vite dying, and the server dying. Each
leaves nothing behind and frees both ports.
KCKrzysztof Cieslak authored
791a620Patch
Parent255065c
3 files changed+117-2
StackedSplit
apps/web/vite.config.ts+12 −1
package.json+1 −1
scripts/dev.ts+104 −0