Skip to content

Commit 9458cbb

Browse files
test(server): stdin observer respects child backpressure
The dispatch observer kept reading stdin while a slow Claude child fell behind, buffering the whole stream in memory. It now pauses stdin when the child's pipe is full and resumes on drain. Forwarded bytes, the shared StringDecoder, the final-line flush, and write failures are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent d4fe68f commit 9458cbb

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎apps/server/src/provider/testFixtures/ClaudeStdin.fixture.mjs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ function record(text) {
4343
}
4444
}
4545
process.stdin.on("data", (chunk) => {
46-
child.stdin.write(chunk);
46+
// Stop reading while the child is behind, so a slow reader cannot grow our buffer unbounded.
47+
if (!child.stdin.write(chunk)) {
48+
process.stdin.pause();
49+
child.stdin.once("drain", () => process.stdin.resume());
50+
}
4751
record(decoder.write(chunk));
4852
});
4953
process.stdin.on("end", () => {

0 commit comments

Comments
 (0)