()
| 22 | |
| 23 | return { |
| 24 | start() { |
| 25 | // Clear any existing timer |
| 26 | if (timer) { |
| 27 | clearTimeout(timer) |
| 28 | timer = null |
| 29 | } |
| 30 | |
| 31 | // Only start timer if delay is configured and valid |
| 32 | if (isValidDelay) { |
| 33 | lastIdleTime = Date.now() |
| 34 | |
| 35 | timer = setTimeout(() => { |
| 36 | // Check if we've been continuously idle for the full duration |
| 37 | const idleDuration = Date.now() - lastIdleTime |
| 38 | if (isIdle() && idleDuration >= delayMs) { |
| 39 | logForDebugging(`Exiting after ${delayMs}ms of idle time`) |
| 40 | gracefulShutdownSync() |
| 41 | } |
| 42 | }, delayMs) |
| 43 | } |
| 44 | }, |
| 45 | |
| 46 | stop() { |
| 47 | if (timer) { |
nothing calls this directly
no test coverage detected