GeezerVison is showing github.com — fix(server): bound shell output capture and shell.output page limit — unbounded file plus uncapped page risks disk exhaustion / OOM · Issue #2486 · developing-today-forks/opencode
fix(server): bound shell output capture and shell.output page limit — unbounded file plus uncapped page risks disk exhaustion / OOM #2486Labels bugSomething isn't workingqueue/parkedQueue task is parked (waiting on CI, time, or an event)status/parkedDeliberately paused with a recorded resume conditiontask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests DescriptionProblem
shell.create captures combined stdout/stderr to a file with no size cap, and shell.output pages it with no upper limit. One verbose / never-ending command (timeout 0 = disabled) can grow the capture file until the disk fills, and one shell.output request with a huge limit tries to materialise up to the whole file in a single Buffer.
Evidence (origin/main 192f3fce43)
packages/schema/src/shell.ts:63-74 — CreateInput has no max_bytes; OutputInput.limit is an unbounded NonNegativeInt.
packages/core/src/shell.ts:37-43,68-71 — outputLimit() explicitly has "no upper clamp" (callers page above the 64 KiB default, so it stays byte-identical); 0 clamps up to a 1-byte page.
packages/core/src/shell.ts:235-263 — output() does Buffer.alloc(Math.min(limit, size - start)); with an uncapped limit a single page allocates up to the whole capture file. truncated is hardcoded false (line 261) even though the schema carries the flag.
packages/core/src/shell.ts:387-397 — the spawn pump appends every chunk to the file and command.size with no max; retention is only count/time-based (EXITED_LIMIT = 25, RETENTION = 7 days, lines 30-33).
packages/core/src/shell.ts:63-66,452-459 — timeout 0 is the disabled sentinel, so the runaway case needs no special input.
- Contrast: VCS diff paths cap output at 10 MiB (
packages/core/src/vcs/patch.ts:22-23 MAX_TOTAL_PATCH_BYTES); shell capture has no equivalent.
Why it matters
The route is location-scoped, but input is agent/model-driven: a faulty yes, verbose build/test loop, or tail -f-style command fills the server disk (affecting all projects/sessions on that host), and a single large shell.output page can OOM the server process. The existing Output.truncated flag gives a natural place to surface capping honestly.
Acceptance criteria
- Captured shell output is bounded (cap + truncate/rotate), so one command cannot exhaust disk.
-
shell.output page limit is clamped (schema and/or service) so one request cannot allocate the whole capture.
-
Output.truncated reflects capping instead of always false.
- Documented defaults/limits; existing callers that legitimately page above 64 KiB (session shell 1 MiB,
result() max_bytes) keep working via paging, not via one giant allocation.
Notes
Activitydezren39 commented on Nov 17, 2026 🤖 Agent note · picked up
- Agent: repo-worker-code (Muse lane any-i)
- Session / ID: queue task 17908
- Found via: atomic unfiltered claim in the one fleet queue (stream repo-health-opencode-pilot), lane any-i; lane assignment direct
- Scope: triage of issue fix(server): bound shell output capture and shell.output page limit — unbounded file plus uncapped page risks disk exhaustion / OOM #2486 — unbounded shell output capture (disk exhaustion) plus an uncapped
shell.output page limit (single-allocation OOM), with Output.truncated hardcoded false. Four acceptance items across packages/schema and packages/core/src/shell.ts; verifying the evidence on current main first, then fixing inline if it stays contained or routing a scoped implementation task.
dezren39 commented on Nov 17, 2026 🤖 Agent note · triage
- Agent: repo-worker-code (Muse lane any-i)
- Session / ID: queue task 17908
- Verdict: CONFIRMED on current main (
f9a80bb213), all four evidence points re-verified this run:
packages/core/src/shell.ts — outputLimit()'s own doc comment states the limit "has no upper clamp"; output() allocates Buffer.alloc(Math.min(limit, size - start)), so one page can allocate the whole capture file, and truncated is hardcoded false.
- The spawn pump appends every chunk to the capture file with no maximum; retention is count/time only (
EXITED_LIMIT = 25, RETENTION = 7 days); timeout 0 is the disabled sentinel, so the runaway case needs no special input.
packages/schema/src/shell.ts — CreateInput has no max_bytes; OutputInput.limit is an unbounded NonNegativeInt. No PR or follow-on covers this issue.
- Routing: the fix spans schema + service + capture pump +
truncated semantics, with a documented byte-identical-paging constraint for existing callers (session shell 1 MiB pages, result() max_bytes) — a scoped implementation task, not an inline triage fix. Enqueued as a follow-on implementation task (small_fix) with the acceptance criteria and design constraints in its packet. This issue stays open as the tracker; labels set: task/small-fix.
dezren39 commented on Nov 17, 2026 🤖 Agent note · correction to the triage note above
- Agent: repo-worker-code (Muse lane any-i)
- Session / ID: queue task 17908
- Correction: the triage note above (comment 6936355003) said the follow-on was enqueued, but that first enqueue attempt was rejected by packet-schema validation and created nothing. The corrected packet has now been accepted: follow-on implementation task 19797 (queue repo-health-opencode-pilot, status queued, dedupe key
repo-health:v1:fix:developing-today-forks/opencode:issue:2486). The triage verdict itself is unchanged.
dezren39 commented on Nov 17, 2026
🤖 Agent note · implemented + targeted tests pass; push in flight — task 19797 (lane any-s)
- Implementation complete in worktree
~/git/fleet/queue-19797-2486-shell-output-cap (laptop), branch queue/19797-2486-shell-output-cap, commit 5f500c4: capture cap MAX_OUTPUT_BYTES 10 MiB (pump drains-and-discards past the cap, marks truncated), page clamp MAX_OUTPUT_PAGE_BYTES 1 MiB in outputLimit(), Output.truncated now reports the capture state, result() accumulates its tail over clamped pages; limits documented in packages/schema/src/shell.ts and at the service boundary.
- Tests:
bun test test/shell-output.test.ts — 6 pass / 0 fail, including the two new fix(server): bound shell output capture and shell.output page limit — unbounded file plus uncapped page risks disk exhaustion / OOM #2486 tests (cap stops growth + truncated reported; oversized page clamped and multi-page reads byte-identical). Wider shell family: 121 pass / 14 fail — every failure is a test-timeout (15s/5s limits) in ShellTool/Session.shell integration tests under extreme laptop load, none an assertion failure and none in the touched unit suites.
- Push in flight:
git push runs detached on the laptop (log /tmp/lane-any-s-19797-push.log); the repo's husky pre-push runs lint + a 41-package typecheck, which was still running at park time. PR body is prepared at /tmp/pr-2486-any-s.md on the laptop.
- Resume: check the push log +
git ls-remote for the branch. If pushed, create the PR from that branch with the prepared body, then merge under standing criteria once checks/CodeRabbit are dispositioned and complete task 19797 as fixed_merged. If the hook failed, read which package failed: the documented pre-existing failure is @opencode/core typecheck in test/session-step.test.ts (see slice 1 (routing): route-overrides API in the OpenCode server #2494) — if the failure is only that, say so on the PR; do not treat it as caused by this change.
Queue: task 19797 (lane any-s) — parked 20 min on the push completing.
MetadataMetadatabugSomething isn't workingqueue/parkedQueue task is parked (waiting on CI, time, or an event)status/parkedDeliberately paused with a recorded resume conditiontask/small-fixQueue packet kind: bounded fix with reproduction and targeted tests DevelopmentNo branches or pull requestsIssue actions
|