fix: fire onSpawn immediately on job terminal transition (FAR-14)

Prevents process_lost false positives for 2-3 minute K8s jobs by
resetting the reaper clock when the keepalive loop detects the job
has completed (or been deleted), rather than waiting for the next
periodic refresh.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Gandalf the Greybeard
2026-04-23 22:29:22 +00:00
parent baf7e2d44d
commit f41ae818ef
+6
View File
@@ -883,6 +883,9 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
if (terminal) {
keepaliveJobTerminal = true;
keepaliveJobTerminalAt = Date.now();
if (ctx.onSpawn) {
void ctx.onSpawn({ pid: process.pid, processGroupId: null, startedAt: new Date().toISOString() }).catch(() => {});
}
return;
}
} catch (err: unknown) {
@@ -893,6 +896,9 @@ export async function execute(ctx: AdapterExecutionContext): Promise<AdapterExec
if (isK8s404(err)) {
keepaliveJobTerminal = true;
keepaliveJobTerminalAt = Date.now();
if (ctx.onSpawn) {
void ctx.onSpawn({ pid: process.pid, processGroupId: null, startedAt: new Date().toISOString() }).catch(() => {});
}
return;
}
// Log transient errors but leave keepaliveJobTerminal false so