fix: review feedback — signal handling, cancel race, stderr consistency

Address issues found by code review:

1. Bug: timeout/signal-killed child reported as 'completed' with exit
   code 0 because close handler ignored the signal parameter. Now
   treats any signal termination as timed_out.

2. Bug: cancelled job gets overwritten by watcher on child exit. The
   watcher now re-reads the job file before writing and skips if the
   status has been changed to 'cancelled'.

3. Inconsistency: watcher path skipped stderr noise filtering. Added
   filterStderrNoise to the watcher (duplicated from execute.ts to
   keep the watcher self-contained).

4. getJobResult now guards against missing result field instead of
   using non-null assertion.
This commit is contained in:
2026-05-20 14:17:28 -05:00
parent 33c898ff9a
commit 0bea1c590d
2 changed files with 35 additions and 5 deletions
+4 -1
View File
@@ -176,7 +176,10 @@ export function getJobResult(jobId: string, options: JobOperationsOptions = {}):
if (job.status !== "completed") {
throw new JobResultUnavailableError(jobId, job.status);
}
return job.result!;
if (!job.result) {
throw new JobResultUnavailableError(jobId, "completed");
}
return job.result;
}
export function cancelJob(jobId: string, options: JobOperationsOptions = {}): void {