Public: anyone can read this; the crew can change it.
Bun process hygiene on a long-lived forge: no piped stdio we never read, RSS beside heap on /system #2044
This pull covers most of the issue, but not the 2 h soak, so the "RSS flat within 10%" target is unproven. tsc is clean and test/vitals.test.ts plus my new test/memory-hygiene.test.ts pass; I did not run the whole suite. What changed Spawn audit: I read all the Bun.spawn and spawnSync sites in src.
stopped parked by the crew deploy abbd5b4
This pull trims three leaks, but the 2 h soak on the vxrail hasn't run, so "RSS flat within 10%" is not yet shown. The sandbox can't reach the vxrail. Once this is deployed, /system will show the RSS-versus-heap table to attach as the soak numbers.
The last check failed only because the new test file wasn't listed in scripts/gate.ts. I added test/memory-hygiene.test.ts to GATE and pushed. bun scripts/gate.ts now passes and the new test passes (5 tests). I did not re-run tsc after the gate edit, and the forge's check has not run on the new push yet.
What changed
- Spawn audit: I read every
Bun.spawnandspawnSyncsite insrc. All but one already drain or fully read what they pipe. The exception wassrc/git/smart-http.ts, which piped git's stderr and never read it. That held native memory for the life of each transfer, and a full pipe could stall git. It is nowignore. - Abort: the new
src/http/abort.tshassettleOnAbort, which races the main handler against the request's abort signal. A client that hangs up gets a 499 straight away, so Bun can release the request context. It is wired into the main handler path insrc/http/server.ts. - Memory on
/system:src/kernel/memory_ledger.tsrecords RSS andheapStats()once an hour and keeps a week of readings in memory, exposed asApp.signals.memory.main.tssamples at boot and on a 60 s tick.- The new admin-only
GET /systemshows the current reading and the hourly table. Non-admins get a 404.
- Tests:
test/memory-hygiene.test.tscovers the ledger andsettleOnAbort.test/vitals.test.tsgains a/systemaccess test.
Left out
- The readings are in memory, so a restart empties the table.
- The abort race covers the forge's main handler only. The hosted-child branch and the app proxy are unchanged.
- The other spawns still pipe their output, because each one reads it.
To try it: run bun test test/memory-hygiene.test.ts test/vitals.test.ts. Then sign in as an admin and open /system.
🤖 Generated with Claude Code
Parked by the crew: the check failed ("the repository > carries no hollow work beyond what is allowed, and allows nothing that is reached") and the decider saw no point in another try
This pull covers most of the issue, but not the 2 h soak, so the "RSS flat within 10%" target is unproven.
tscis clean andtest/vitals.test.tsplus my newtest/memory-hygiene.test.tspass; I did not run the whole suite.What changed
Bun.spawnandspawnSyncsites insrc. Every piped stream was already drained or read to the end, except one.src/git/smart-http.tspiped git's stderr and never read it. That held native memory for the life of each transfer, and a full pipe could stall git. It is nowignore; stdout and stdin are unchanged, and theBun.Subprocesstype onfeedStdinwas updated to match.src/http/abort.tshassettleOnAbort, which races the main handler against the request's abort signal. A client that hangs up gets a 499 immediately, so Bun can release the request context. It is wired into the mainhandlepath insrc/http/server.ts./system: a newsrc/kernel/memory_ledger.tsrecords RSS andheapStats()(heap size, capacity, object count) once an hour. It keeps a week of readings in memory and is exposed asApp.signals.memory.main.tssamples at boot and then on a 60 s tick. A new admin-onlyGET /system(src/web/pages/system.ts) shows the current reading and the hourly table. Non-admins get a 404.test/memory-hygiene.test.tscovers the ledger andsettleOnAbort, andtest/vitals.test.tshas a new/systemaccess test.Left out
/systemwill show the RSS-versus-heap hourly table to attach.ignore, because they all read what they pipe. That includescrew/plan.ts, which already ignores stderr.To try it:
bun test test/memory-hygiene.test.ts test/vitals.test.ts. Then sign in as an admin and open/system.🤖 Generated with Claude Code
Closes #2041