mirror of
https://github.com/wu736139669/hapi.git
synced 2026-08-05 06:24:37 +00:00
fix: handle abort signal before and during codex spawn
Add checks to gracefully handle abort signals: - Check if abort is already signaled before attempting spawn - Check if abort caused the spawn error instead of rejecting
This commit is contained in:
@@ -52,6 +52,11 @@ export async function codexLocal(opts: {
|
||||
|
||||
logger.debug(`[CodexLocal] Spawning codex with args: ${JSON.stringify(args)}`);
|
||||
|
||||
if (opts.abort.aborted) {
|
||||
logger.debug('[CodexLocal] Abort already signaled before spawn; skipping launch');
|
||||
return;
|
||||
}
|
||||
|
||||
process.stdin.pause();
|
||||
try {
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
@@ -95,6 +100,10 @@ export async function codexLocal(opts: {
|
||||
|
||||
child.on('error', (error) => {
|
||||
cleanupAbortHandler();
|
||||
if (opts.abort.aborted) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
reject(new Error(`Failed to spawn codex: ${message}. Is Codex CLI installed and on PATH?`, { cause: error }));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user