fix(retry): resolve message delivery speed

fix(retry): resolve message delivery speed
This commit is contained in:
Renato Alcara
2026-02-26 22:09:18 -03:00
committed by GitHub
parent 416ad47789
commit d73f2d0fc3
4 changed files with 53 additions and 20 deletions
+4
View File
@@ -716,6 +716,10 @@ export function createConnectionCircuitBreaker(customOptions?: Partial<CircuitBr
resetTimeout: 60000,
successThreshold: 1,
shouldCountError: (error: Error) => {
// CircuitTimeoutError messages embed the circuit name (e.g. "socket-query"), which
// accidentally matches the "socket" pattern below and causes a self-reinforcing loop
// where the breaker's own timeouts keep tripping the breaker. Exclude them explicitly.
if (error instanceof CircuitTimeoutError) return false
const message = error.message.toLowerCase()
const code = (error as NodeJS.ErrnoException).code?.toLowerCase() || ''
return connectionErrorPatterns.some(pattern => message.includes(pattern) || code.includes(pattern))
+7 -1
View File
@@ -174,7 +174,13 @@ export class MessageRetryManager {
// (device suffix present/absent, LID vs PN, etc.)
const indexedKeyStr = this.messageKeyIndex.get(id)
if (indexedKeyStr) {
return this.recentMessagesMap.get(indexedKeyStr)
const message = this.recentMessagesMap.get(indexedKeyStr)
if (!message) {
// The LRU cache evicted this entry; clean up the stale index reference
// to prevent repeated futile lookups on subsequent retry receipts.
this.messageKeyIndex.delete(id)
}
return message
}
return undefined