Skip to content

Commit 5d3ec46

Browse files
committed
fix(codex-adapter): emit cancelled events on worker exit
Addressed review feedback about potential stream hangs when the Codex worker exits cleanly before emitting run results by injecting explicit cancelled and error events ahead of the iterator teardown. This ensures stream consumers always observe terminal metadata (cancelled + error + done) before the iterator finishes. Verified via npm run test --workspace examples.
1 parent b12a184 commit 5d3ec46

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/codex-adapter/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,9 @@ export class CodexAdapter implements HeadlessCoder {
395395
push(DONE);
396396
return;
397397
}
398-
push(createWorkerExitError(`Codex worker exited with code ${code}`, stderrOutput));
398+
const reason = `Codex worker exited with code ${code}`;
399+
push(createCancelledEvent(reason, stderrOutput));
400+
push(createWorkerExitErrorEvent(reason, stderrOutput));
399401
push(DONE);
400402
});
401403

0 commit comments

Comments
 (0)