fix(signal): critical fixes for identity key detection - batch 1
High Priority Fixes based on Copilot/Codex code review: 1. Propagate errorCode to shouldRecreateSession (CRITICAL) - Extract error attribute from retry node - Pass errorCode to shouldRecreateSession in both sendRetryRequest and sendMessagesAgain - Without this fix, MAC error detection was NOT working - Now immediate session recreation works for MAC errors 2. Use .unref() on metrics interval - Prevents blocking process exit in short-lived scripts/tests - Interval no longer keeps event loop alive unnecessarily 3. Reset circuit breaker regardless of state - Previously only reset when isOpen() - Now resets in any state (open, half-open, or closed with accumulated failures) - Ensures clean slate after identity change detection https://claude.ai/code/session_01SWAcNuGZQmEKyBPYkBhVHg
This commit is contained in:
@@ -255,9 +255,9 @@ export function makeLibSignalRepository(
|
||||
metrics.signalIdentityKeyCacheSize?.set(identityKeyCache.size)
|
||||
}, 60000) // Every minute
|
||||
|
||||
// Cleanup interval on process exit
|
||||
if (typeof process !== 'undefined') {
|
||||
process.on('beforeExit', () => clearInterval(cacheMetricsInterval))
|
||||
// Allow process to exit even with interval active (prevents blocking in short-lived scripts/tests)
|
||||
if (typeof cacheMetricsInterval.unref === 'function') {
|
||||
cacheMetricsInterval.unref()
|
||||
}
|
||||
|
||||
const storage = signalStorage(auth, lidMapping, identityKeyCache, ev, preKeyCircuitBreaker, logger)
|
||||
@@ -334,7 +334,8 @@ export function makeLibSignalRepository(
|
||||
)
|
||||
|
||||
// Reset prekey circuit breaker since we identified the cause
|
||||
if (preKeyCircuitBreaker?.isOpen()) {
|
||||
// Reset regardless of state (could be open, half-open, or closed with accumulated failures)
|
||||
if (preKeyCircuitBreaker) {
|
||||
preKeyCircuitBreaker.reset()
|
||||
logger.debug({ jid }, 'Reset prekey circuit breaker after identity key change detection')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user