Skip to content

Commit 6951561

Browse files
committed
fix(gemini-adapter): defer stdout close completion
Resolved the regression where the readline close handler marked Gemini streams as finished before the child process exited, which hid non-zero exit codes. The handler now only finalizes when an abort is already in progress so the exit listener can propagate real CLI failures. Verified via npm run test --workspace examples.
1 parent b7f575b commit 6951561

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

packages/gemini-adapter/src/index.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -248,18 +248,16 @@ export class GeminiAdapter implements HeadlessCoder {
248248
};
249249
rl.on('line', handleLine);
250250
const handleClose = () => {
251-
if (finished) return;
251+
if (finished || !active.aborted) return;
252252
finished = true;
253-
if (active.aborted) {
254-
const reason = active.abortReason ?? 'Interrupted';
255-
push({
256-
type: 'cancelled',
257-
provider: CODER_NAME,
258-
ts: now(),
259-
originalItem: { reason },
260-
});
261-
push(interruptedErrorEvent(reason));
262-
}
253+
const reason = active.abortReason ?? 'Interrupted';
254+
push({
255+
type: 'cancelled',
256+
provider: CODER_NAME,
257+
ts: now(),
258+
originalItem: { reason },
259+
});
260+
push(interruptedErrorEvent(reason));
263261
push(DONE);
264262
};
265263
rl.once('close', handleClose);

0 commit comments

Comments
 (0)