| 463 | } |
| 464 | |
| 465 | private end(cause: Error): void { |
| 466 | if (this.exited) return |
| 467 | this.exited = true |
| 468 | for (const timer of this.timers.values()) clearTimeout(timer) |
| 469 | this.timers.clear() |
| 470 | if (!this.ready) this.unref() |
| 471 | const unacknowledged = new Error( |
| 472 | "The proxy process stopped after the command was sent to it but before it replied, so the command may have started", |
| 473 | { cause } |
| 474 | ) |
| 475 | const lost = new Error("The proxy process exited before the command's exit status was received", { cause }) |
| 476 | // Every command is marked lost before anything else can run |
| 477 | const reports = Array.from( |
| 478 | this.commands.values(), |
| 479 | (command) => command.onLost(command.pid !== undefined ? lost : unacknowledged) |
| 480 | ) |
| 481 | this.disconnect() |
| 482 | for (const report of reports) report() |
| 483 | // Has no effect on a proxy process that was ready |
| 484 | Deferred.doneUnsafe(this.started, Exit.fail(cause)) |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | const toStartError = (options: Options) => (error: NodeJS.ErrnoException): PlatformError.PlatformError => { |