()
| 162 | |
| 163 | let stopping = false; |
| 164 | const stop = async (): Promise<void> => { |
| 165 | if (stopping) { |
| 166 | await child.exited; |
| 167 | return; |
| 168 | } |
| 169 | stopping = true; |
| 170 | for (const signal of viteChildSignals) process.off(signal, stopOnParentSignal); |
| 171 | if (child.exitCode === null) child.kill(); |
| 172 | await Promise.race([child.exited, Bun.sleep(5_000)]); |
| 173 | if (child.exitCode === null) child.kill("SIGKILL"); |
| 174 | await child.exited; |
| 175 | }; |
| 176 | const stopOnParentSignal = (): void => { |
| 177 | // A PTY/session teardown can signal the CLI while Vite is still optimizing |
| 178 | // dependencies, before the server's normal stop handle exists. Reap the |
no test coverage detected