| 454 | // detected pre-spawn or as a libuv ECHILD/ENOENT/etc on the |
| 455 | // child itself. |
| 456 | private spawnFailed(id: string, err: unknown): ExecHandle { |
| 457 | const message = err instanceof Error ? err.message : String(err); |
| 458 | const log = createLog(this.db, id, { |
| 459 | maxBytes: this.opts.logMaxBytes, |
| 460 | now: this.opts.now, |
| 461 | }); |
| 462 | const value = new TextEncoder().encode(`spawn failed: ${message}\n`); |
| 463 | const stderrSeq = log.append("stderr", value); |
| 464 | const exitSeq = log.setExit(-1); |
| 465 | log.dispose(); |
| 466 | const events = new ReadableStream<ExecEvent>({ |
| 467 | start(controller) { |
| 468 | controller.enqueue({ id, seq: stderrSeq, name: "stderr", value }); |
| 469 | controller.enqueue({ id, seq: exitSeq, name: "exit", value: -1 }); |
| 470 | controller.close(); |
| 471 | }, |
| 472 | }); |
| 473 | return { id, events }; |
| 474 | } |
| 475 | |
| 476 | private scheduleSweep(): void { |
| 477 | if (this.sweepTimer !== undefined) return; |