docs(relay): trim the pending-output drain comment (#10714)

Co-authored-by: Orca <help@stably.ai>
This commit is contained in:
Neil 2026-07-26 00:52:04 -07:00 committed by GitHub
parent 15c0e4bc7c
commit 54e22402bc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 5 deletions

View File

@ -723,11 +723,8 @@ export class PtyHandler {
private flushPendingOutput(): void {
this.outputFlushTimer = null
// Why: the send loop has no skip path and stops at PTY_OUTPUT_FLUSH_MAX_WRITES, so it can never
// reach a third entry — `Array.from(entries())` allocated one tuple per session every tick to
// consume at most two. Capture only that prefix, and capture it *before* the first send so a
// re-entrant sink still reads the values a whole-map snapshot would have frozen.
// Why the explicit iterator: `for...of` would advance one tuple past the limit and discard it.
// Why batch before the first send: a re-entrant sink must read the values a whole-map snapshot
// would have frozen. Why the raw iterator: `for...of` would consume one entry past the limit.
const pendingEntries = this.pendingOutputByPty[Symbol.iterator]()
const batch: [string, PendingPtyOutput][] = []
while (batch.length < PTY_OUTPUT_FLUSH_MAX_WRITES) {