()
| 92 | let healthCheckInFlight = false // Guard against stacking health checks |
| 93 | |
| 94 | const triggerLost = () => { |
| 95 | if (isReleased || lostTriggered) return |
| 96 | lostTriggered = true |
| 97 | logLock('warn', 'Lock lost detected, triggering lost callback', { lockId, healthCheckCount }) |
| 98 | if (healthCheckTimer) { |
| 99 | clearInterval(healthCheckTimer) |
| 100 | healthCheckTimer = null |
| 101 | } |
| 102 | // Close the connection before marking as released |
| 103 | connection.end().catch(() => {}) |
| 104 | isReleased = true |
| 105 | if (lostCallback) { |
| 106 | lostCallback() |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | // Start health check interval - verify we still hold the lock, not just connection liveness |
| 111 | healthCheckTimer = setInterval(async () => { |
no test coverage detected