better status check

This commit is contained in:
Chris Wanstrath 2026-02-15 09:10:04 -08:00
parent 6b70af2943
commit f3cc26252c

View File

@ -644,12 +644,8 @@ async function runApp(dir: string, port: number) {
const survivalThreshold = 5000 // Consider non-HTTP apps running after 5s
const startTime = Date.now()
// Use proc.exited as the authoritative death signal instead of ps(1)
let processExited = false
proc.exited.then(() => { processExited = true })
while (app.state === 'starting' && app.proc === proc) {
if (processExited) {
if (proc.exitCode !== null) {
info(app, 'Process died during startup')
return
}
@ -680,10 +676,7 @@ async function runApp(dir: string, port: number) {
// If process survived long enough, consider it running (non-HTTP app)
if (Date.now() - startTime >= survivalThreshold) {
// One final check — process could have died between loop iterations
// Yield to let proc.exited handler run if pending
await new Promise(resolve => setTimeout(resolve, 0))
if (processExited) {
if (proc.exitCode !== null) {
info(app, 'Process died during startup')
return
}