fix: drain stdout before resolving when a child holds the pipe past exit (#5753)

This commit is contained in:
Joseph Mearman
2026-06-15 08:55:45 +01:00
committed by GitHub
parent 408ac103ec
commit 3fa4095629
4 changed files with 134 additions and 5 deletions

View File

@@ -289,6 +289,7 @@ export function createBashToolDefinition(
const resolvedCommand = commandPrefix ? `${commandPrefix}\n${command}` : command;
const spawnContext = resolveSpawnContext(resolvedCommand, cwd, spawnHook);
const output = new OutputAccumulator({ tempFilePrefix: "pi-bash" });
let acceptingOutput = true;
let updateTimer: NodeJS.Timeout | undefined;
let updateDirty = false;
let lastUpdateAt = 0;
@@ -334,11 +335,13 @@ export function createBashToolDefinition(
}
const handleData = (data: Buffer) => {
if (!acceptingOutput) return;
output.append(data);
scheduleOutputUpdate();
};
const finishOutput = async () => {
acceptingOutput = false;
output.finish();
clearUpdateTimer();
emitOutputUpdate();