( platform: NodeJS.Platform, exit: (code: number) => void, )
| 93 | * so callers/tests can clear it. |
| 94 | */ |
| 95 | export function finalizeDaemonExit( |
| 96 | platform: NodeJS.Platform, |
| 97 | exit: (code: number) => void, |
| 98 | ): NodeJS.Timeout | null { |
| 99 | if (platform === 'win32') { |
| 100 | process.exitCode = 0; |
| 101 | const backstop = setTimeout(() => exit(0), DAEMON_SHUTDOWN_BACKSTOP_MS); |
| 102 | // Unref so it never keeps the loop alive: a natural drain (watchers closed, |
| 103 | // nothing else pending) exits before it fires; it only fires when some other |
| 104 | // handle is keeping the loop running, which is exactly when we need it. |
| 105 | backstop.unref?.(); |
| 106 | return backstop; |
| 107 | } |
| 108 | exit(0); |
| 109 | return null; |
| 110 | } |
| 111 | |
| 112 | /** How often the daemon sweeps connected clients for a dead peer process (#692). */ |
| 113 | const DEFAULT_CLIENT_SWEEP_MS = 30_000; |
no outgoing calls
no test coverage detected