Skip to content

Commit 383db06

Browse files
fix(provider-acp): wait_for_exit answers when a background child holds the output pipes
The exit handler waited for stdout and stderr to reach EOF before publishing the exit status. A detached child that inherits the pipes keeps them open, so terminal/wait_for_exit never answered and the turn stalled. Give the output pumps a short grace to drain after exit, then publish the status; the pumps keep appending any later output. Fixes #28067 AI-assisted; verified with the tests and tools listed above.
1 parent e912ca1 commit 383db06

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎packages/provider-acp/src/server/clientTerminals.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const MAX_RETAINED_TERMINALS = 32;
1919
const MAX_RETAINED_OUTPUT_BYTES = 16 * 1024 * 1024;
2020
const DEFAULT_OUTPUT_BYTE_LIMIT = 4 * 1024 * 1024;
2121
const MAX_OUTPUT_BYTE_LIMIT = 8 * 1024 * 1024;
22+
const OUTPUT_DRAIN_GRACE = "1 second";
2223

2324
const terminalRequestError = (message: string, cause?: unknown) =>
2425
EffectAcpErrors.AcpRequestError.internalError(
@@ -301,6 +302,8 @@ export const makeAcpClientTerminals = Effect.fn("makeAcpClientTerminals")(functi
301302
Effect.all([Fiber.join(stdoutPump), Fiber.join(stderrPump)], {
302303
discard: true,
303304
}).pipe(
305+
// A background child can inherit the pipes and hold them open indefinitely.
306+
Effect.timeoutOption(OUTPUT_DRAIN_GRACE),
304307
Effect.andThen(
305308
Effect.sync(() => {
306309
record.exitStatus = status;

0 commit comments

Comments
 (0)