You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Runner supervising turbo run dev vs spawning each service with Effect 4's ChildProcess (effect/unstable/process): which gives clean Ctrl-C / stop teardown of server + embedded-postgres, survives the agent's shell exiting (daemonised start, later attach), runs two worktrees side by side without cross-talk, and produces logs an agent can read (per-service prefixed lines, not interleaved noise)?
Throwaway prototype; the answer becomes a requirement on the Effect v4 port map. Input: Local dev environment resolution.
Both variants start embedded-postgres in-process identically; they differ only in how the server is launched — turbo run dev as one child, or tsx watch src/start.ts spawned directly with effect/unstable/process. The supervisor is an Effect scope: postgres is acquireRelease, the service is spawner.spawn (scoped, forceKillAfter: 5s), start spawns the supervisor detached + unref and polls /healthz.
Results against the four criteria
criterion
turbo
Effect ChildProcess
Ctrl-C on foreground up
clean, ~150 ms, 0 leftovers
clean, ~150 ms, 0 leftovers
daemonised start → shell exits → stop later
clean, 0 leftovers
clean, 0 leftovers
two worktrees side by side
both healthy on hashed ports; no turbo daemon spawned; stopping one leaves the other up
same
logs
[turbo] @patchy/server:dev: … double prefix plus turbo banner, deprecation warning and npm notice lines
[server] …, nothing else
Teardown is equal because both go through the same Effect scope: NodeRuntime.runMain maps SIGINT/SIGTERM to interruption, finalizers kill the service then stop postgres. Turbo does forward SIGTERM to its tsx watch grandchildren correctly.
What turbo cost that Effect didn't
Strict env mode stripped PORT and DATABASE_URL. First turbo run silently started the server on :3000 against the JSON DB — exactly the cross-worktree collision the plan exists to prevent. Fix is --env-mode=loose or declaring every service env var in turbo.json; the effect variant passes env directly.
Needs the package-manager binary on PATH.Unable to find package manager binary on this machine (pnpm via mise); the effect variant spawns tsx from node_modules/.bin and doesn't care.
--parallel is deprecated in turbo 2.10; the replacement is persistent/with task config — more turbo.json to own for a dev task that has cache: false and no graph anyway.
Four extra process layers (turbo node shim → turbo binary → pnpm → tsx) and a .turbo/ dir per worktree.
Turbo bought nothing here: with one persistent, uncached dev task there is no graph to schedule, and the runner already owns the plan.
Other facts surfaced
handle.exitCode is the only thing needed to make a service crash tear the supervisor (and postgres) down — my first cut sat on Effect.never and a dead turbo left postgres running for a minute. Same one-liner in both variants.
embedded-postgres initdb took ~5.7 s, of which 5.4 s was "syncing data to disk" — initdbFlags: ["--no-sync"] should bring it near the ~300 ms the options ticket quoted. First start otherwise ~1 s.
Running the runner under tsx puts a wrapper pid between start's handle and the supervisor's process.pid; the real runner should run under node --import tsx or be built, so plan.json's pid is the one signals reach.
.local/dev/ contents from the prototype: pg/, dev.log, plan.json, storage/ — matches the local-dev decision.
Recommendation
Spawn each service directly with Effect's ChildProcess; drop turbo from the dev path (keep it for build/test/lint). Requirement for the port map: the runner is an Effect scope that owns every service handle; teardown is scope closure; start = detached self-spawn + unref + health poll.
Spawn each service directly with Effect 4's ChildProcess (effect/unstable/process); turbo is not on the dev path (it stays for build/test/lint). Decided with Allison, 2026-08-26, on the prototype findings (branch prototype/dev-runner-supervisor, throwaway — not merged).
Requirements the Effect v4 port map inherits:
The runner is an Effect scope that owns every service handle: postgres via acquireRelease, each service via spawner.spawn with killSignal: SIGTERM + forceKillAfter. Teardown is scope closure; NodeRuntime.runMain maps SIGINT/SIGTERM to interruption. Any service's exitCode closes the scope, so a crashed service takes the instance down rather than leaving postgres orphaned.
start = spawn the supervisor detached, unref it, poll /healthz; stop = SIGTERM the supervisor pid recorded in plan.json. Run the supervisor under node --import tsx (or built), never the tsx CLI wrapper, so the recorded pid is the one signals reach.
Env goes straight to each child (no strict-mode declaration layer); log lines carry one [service] prefix written by the runner.
initdb with --no-sync (the 5 s fsync dominated first start).
Activity
allisonmahmood commentedon Aug 26, 2026
Prototype findings (not the resolution — awaiting Allison's pick)
Prototype: branch
prototype/dev-runner-supervisor, filescripts/dev-proto/dev.ts. One runner, two supervisors selected by argument:Both variants start embedded-postgres in-process identically; they differ only in how the server is launched —
turbo run devas one child, ortsx watch src/start.tsspawned directly witheffect/unstable/process. The supervisor is an Effect scope: postgres isacquireRelease, the service isspawner.spawn(scoped,forceKillAfter: 5s),startspawns the supervisordetached+unrefand polls/healthz.Results against the four criteria
upstart→ shell exits →stoplater[turbo] @patchy/server:dev: …double prefix plus turbo banner, deprecation warning andnpm noticelines[server] …, nothing elseTeardown is equal because both go through the same Effect scope:
NodeRuntime.runMainmaps SIGINT/SIGTERM to interruption, finalizers kill the service then stop postgres. Turbo does forward SIGTERM to itstsx watchgrandchildren correctly.What turbo cost that Effect didn't
PORTandDATABASE_URL. First turbo run silently started the server on:3000against the JSON DB — exactly the cross-worktree collision the plan exists to prevent. Fix is--env-mode=looseor declaring every service env var inturbo.json; the effect variant passes env directly.Unable to find package manager binaryon this machine (pnpm via mise); the effect variant spawnstsxfromnode_modules/.binand doesn't care.--parallelis deprecated in turbo 2.10; the replacement ispersistent/withtask config — more turbo.json to own for adevtask that hascache: falseand no graph anyway..turbo/dir per worktree.Turbo bought nothing here: with one persistent, uncached
devtask there is no graph to schedule, and the runner already owns the plan.Other facts surfaced
handle.exitCodeis the only thing needed to make a service crash tear the supervisor (and postgres) down — my first cut sat onEffect.neverand a dead turbo left postgres running for a minute. Same one-liner in both variants.initdbtook ~5.7 s, of which 5.4 s was "syncing data to disk" —initdbFlags: ["--no-sync"]should bring it near the ~300 ms the options ticket quoted. First start otherwise ~1 s.tsxputs a wrapper pid betweenstart's handle and the supervisor'sprocess.pid; the real runner should run undernode --import tsxor be built, so plan.json's pid is the one signals reach..local/dev/contents from the prototype:pg/,dev.log,plan.json,storage/— matches the local-dev decision.Recommendation
Spawn each service directly with Effect's
ChildProcess; drop turbo from the dev path (keep it for build/test/lint). Requirement for the port map: the runner is an Effect scope that owns every service handle; teardown is scope closure;start= detached self-spawn + unref + health poll.allisonmahmood commentedon Aug 26, 2026
Resolution
Spawn each service directly with Effect 4's
ChildProcess(effect/unstable/process); turbo is not on the dev path (it stays for build/test/lint). Decided with Allison, 2026-08-26, on the prototype findings (branchprototype/dev-runner-supervisor, throwaway — not merged).Requirements the Effect v4 port map inherits:
acquireRelease, each service viaspawner.spawnwithkillSignal: SIGTERM+forceKillAfter. Teardown is scope closure;NodeRuntime.runMainmaps SIGINT/SIGTERM to interruption. Any service'sexitCodecloses the scope, so a crashed service takes the instance down rather than leaving postgres orphaned.start= spawn the supervisordetached,unrefit, poll/healthz;stop= SIGTERM the supervisor pid recorded inplan.json. Run the supervisor undernode --import tsx(or built), never thetsxCLI wrapper, so the recorded pid is the one signals reach.[service]prefix written by the runner.initdbwith--no-sync(the 5 s fsync dominated first start).docs(whats-new): older single-file pages run the same way as new ones (…