Repository navigation
Open
Labels
enhancementNew feature or request
Milestone
Description
Recorded from #184's measurement and the maintainer's decision of 2026-10-26: the PTY receive queue stays
unbounded in 1.0, and an opt-in bound is a 1.1 feature.
What
A PtySession or PersistentPtySession that nobody reads keeps every output frame (ADR-0023). The macro harness in
#647 and a live probe against our own pinned server (Windows, net10.0 and net472) measured what that costs:
PtySession (text frames) |
PersistentPtySession (binary frames) |
|
|---|---|---|
| Retained per queued frame | about 2 bytes per output character (1.96x the payload at 16 KiB frames) | about 1 byte per byte |
| Verbose build log (~250K chars/s) | about 30 MB per minute | about half |
git log --stat burst (~180-200K chars/s) |
about 21-25 MB per minute while it lasts | about half |
| Flood ceiling (~1.6M chars/s, net10.0) | up to about 195 MB per minute | about half |
An idle shell grows by next to nothing.
Upstream
Upstream is unbounded on the live path too (v2.1.4):
- its client returns a raw
WebSocket(packages/client/src/solid/pty.ts:23-40); - its consumers push every message into a handler (
packages/tui/src/component/terminal-pane.tsx:132-135,197-206); - the server's per-connection outbox is
Queue.unbounded(packages/server/src/handlers/pty.ts:139,
packages/server/src/handlers/persistent-pty.ts:126).
Its only bound is the replay ring, BUFFER_LIMIT = 2 MiB (packages/core/src/pty.ts:12,218-222), which bounds what a
reconnect can replay, not what a live connection queues.
So a bound here would be beyond upstream: an additive SDK feature, recorded as such.
Proposal
- An opt-in, per-connection limit on
PtyConnectOptionsandPersistentPtyConnectOptions: a byte or frame cap, off
by default, so 1.0's behaviour doesn't change. - An explicit overflow policy: end the session with a typed failure, or drop the oldest frames. The policy is the
decision this issue carries. - The reference figure is upstream's 2 MiB replay window.
- It's additive public API (an option property), so it can land in 1.1 without breaking 1.0 consumers.
Evidence
src/OpenCode.Sdk/Internal/Terminal/TerminalReceivePump.cs:13(Channel.CreateUnbounded).docs/adr/0023-terminal-consumer-cancellation.md:7-11(a memory limit and an overflow policy
need workload evidence).- Both options types are sealed classes with init-only members.
Done when
- The option and its overflow policies are designed from Measure the PTY receive queue under slow, absent and burst consumers #184's numbers, implemented, and tested
per policy, with docs and CHANGELOG; or this issue closes with the evidence that no bound is
needed.
Related
- Opt-in bound for the terminal receive queue #195 tracked the same bound and is closed as a duplicate of this issue.
- The terminal send path's allocation (about 1 KB per keystroke) was measured and closed for 1.0 as structural. Its
primitive breakdown is recorded in the maintainers' notes.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Type
Projects
- StatusShow more project fieldsQueue
Activity