()
| 568 | }; |
| 569 | |
| 570 | const shutdown = async (): Promise<void> => { |
| 571 | // Drop the cache entry first so a concurrent request starts a fresh |
| 572 | // container rather than reusing one that's being torn down. |
| 573 | runningContainers.delete(reuseKey); |
| 574 | try { |
| 575 | // `docker stop` causes the foreground `docker run --rm` to exit and |
| 576 | // removes the container. |
| 577 | await runForwarded('docker', ['stop', containerName], out, { |
| 578 | quiet: true, |
| 579 | }); |
| 580 | } catch (err) { |
| 581 | debug( |
| 582 | `docker stop ${containerName} failed: ${(err as Error).message}` |
| 583 | ); |
| 584 | } finally { |
| 585 | cleanupEnvFile(); |
| 586 | } |
| 587 | }; |
| 588 | |
| 589 | // Poll for Docker's assigned host port. Any failure funnels through |
| 590 | // `shutdown()` so the container is stopped and the temp env-file (which |
no test coverage detected