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 #2062

Parked opened this in answer to
Closed without merging

I fixed the spawned processes that piped output nobody read, made a request whose client hangs up settle at once with 499, and added RSS beside heap hour by hour to the capacity page. The 2-hour vxrail soak is not done: it needs the vxrail, which this sandbox can't reach.

Notes

stopped parked by the crew deploy 5575937

opened this

I fixed the spawned processes that piped output nobody read, made a request whose client hangs up settle at once with 499, and added RSS beside heap hour by hour to the capacity page. The 2-hour vxrail soak is not done: it needs the vxrail, which this sandbox can't reach. I opened it as #2061 and set #2041 to wait for it, so this pull has no soak numbers yet.

Unread pipes. Four processes piped output that nothing read, which holds native memory for the child's life and stalls the child once the pipe fills. Each now ignores that output:

  • src/git/smart-http.ts: git's stderr on every clone and push over HTTP. This is the busiest one.
  • src/crew/claude.ts: stderr from detectClaude (claude --version).
  • src/cli/config.ts: stderr from the keychain security call.
  • src/chaos/invariants.ts: a spawnSync that collected output by default.

The new test/spawn_stdio.test.ts reads every Bun.spawn/spawnSync in src and names any stream that is piped, by name or by Bun's default, without being read. It flagged exactly these four on main.

499 on abort. The new src/http/abort.ts (settleOnAbort) is wrapped around the server's single fetch in src/http/server.ts, so it covers every route. If the client hangs up, the request answers 499 straight away and Bun can release its context. The handler still runs to its end, and a handler error before any hang-up still reaches error().

RSS beside heap. The issue asked for this on /system, but there is no such page. The last attempt (#2044) added one that nothing linked to, and the hollow-work audit failed it. So it goes on the existing admin page /settings/capacity, in a new Memory card:

  • the resident size now, beside the heap size, heap capacity and object count from bun:jsc heapStats();
  • how far each has moved over the hours kept;
  • a table with the latest reading of each hour for two days.

The new src/kernel/memory_hours.ts (App.signals.memory) holds the readings, and main.ts takes one every ten minutes. They are kept in memory only, so a restart empties the table.

Tests.

  • New: test/spawn_stdio.test.ts, test/memory_hours.test.ts, test/settle_on_abort.test.ts, and an admin-only Memory case in test/capacity.test.ts.
  • The three new files are added to GATE after 10/10 green runs each (flake-hunt admit).
  • tsc, scripts/gate.ts, the hollow-work audit and check-list pass, as do the HTTP, SSE, git-clone and XSS suites.

Failures that are not from this change:

  • In test/capacity.test.ts, "an admin changes each one…" fails at the FORGE_CHECK_SHARDS reset, with and without these commits.
  • push-through and origins-reconnect time out after 5 s here, with and without these commits.

To try it: run bun test test/spawn_stdio.test.ts test/memory_hours.test.ts test/settle_on_abort.test.ts test/capacity.test.ts, then sign in as an admin and open /settings/capacity#memory.

🤖 Generated with Claude Code

Closes #2041

commented

Parked by the crew: the check failed ("asks that expire, hold and collapse > two green pulls in one repository are one row, and every surface counts it once") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs