(code: number | null, signal: NodeJS.Signals | null)
| 340 | }; |
| 341 | |
| 342 | const onExit = (code: number | null, signal: NodeJS.Signals | null) => { |
| 343 | if (resolved) { |
| 344 | // Post-boot exit: expected when we stopped it ourselves (quit, |
| 345 | // restart, update); anything else is a sidecar crash under a live |
| 346 | // window — log it and report upstream with the stderr tail. |
| 347 | if (expectedExits.has(child)) { |
| 348 | sidecarLog.info(`exited (code=${code} signal=${signal})`); |
| 349 | return; |
| 350 | } |
| 351 | const message = `Sidecar exited unexpectedly (code=${code} signal=${signal})`; |
| 352 | sidecarLog.error(message); |
| 353 | reportSidecarCrash(message, stderrBuffer); |
| 354 | unexpectedExitListener?.(); |
| 355 | return; |
| 356 | } |
| 357 | if (rejected) return; |
| 358 | // Detect bind failure — the Node listener prints either "EADDRINUSE" or |
| 359 | // "address already in use" on stderr before exiting non-zero. |
| 360 | if (/EADDRINUSE|address already in use/i.test(stderrBuffer)) { |
| 361 | reject(new SidecarPortInUseError(settings.port)); |
| 362 | return; |
| 363 | } |
| 364 | const message = `Sidecar exited before ready (code=${code} signal=${signal}). Stderr:\n${stderrBuffer}`; |
| 365 | // oxlint-disable-next-line executor/no-error-constructor -- boundary: sidecar boot failure surfaces here as a rejected start promise |
| 366 | reject(new Error(message)); |
| 367 | }; |
| 368 | |
| 369 | child.stdout?.on("data", onStdout); |
| 370 | child.stderr?.on("data", onStderr); |
nothing calls this directly
no test coverage detected