chore(logs): reduce decrypt-error noise (~75% fewer lines per recover… (#391)
chore(logs): reduce decrypt-error noise (~75% fewer lines per recover… (#391)
This commit is contained in:
+11
-2
@@ -28,7 +28,16 @@ console.info = function (...args: unknown[]) {
|
||||
|
||||
// Track errors by type + JID to avoid duplicates (using Map for better performance)
|
||||
const _errorTimestamps = new Map<string, number>()
|
||||
const DEDUP_WINDOW_MS = 150
|
||||
// Dedup window for repeated decrypt-error console lines (Bad MAC / Counter / etc).
|
||||
// Was 150ms, but retry attempts of the SAME message are typically ~300-1000ms apart,
|
||||
// so the second attempt fell outside the window and double-printed.
|
||||
//
|
||||
// TRADE-OFF: dedup key is `errorType + JID` (no message-id). With 5s, a burst of
|
||||
// errors for the SAME JID — even of slightly different categories or different
|
||||
// messages — collapses to one log line every 5s. This is intentional for a noisy
|
||||
// production stream; if you need per-message visibility, set BAILEYS_LOG_LEVEL=debug
|
||||
// to bypass this console-side dedup and see the structured pino logs in full.
|
||||
const DEDUP_WINDOW_MS = 5000
|
||||
|
||||
console.error = function (...args: unknown[]) {
|
||||
if (args.length > 0 && typeof args[0] === 'string') {
|
||||
@@ -70,7 +79,7 @@ console.error = function (...args: unknown[]) {
|
||||
const lastTime = _errorTimestamps.get(dedupeKey)
|
||||
|
||||
if (lastTime && now - lastTime < DEDUP_WINDOW_MS) {
|
||||
return // Skip duplicate within 150ms window
|
||||
return // Skip duplicate within DEDUP_WINDOW_MS window
|
||||
}
|
||||
|
||||
_errorTimestamps.set(dedupeKey, now)
|
||||
|
||||
Reference in New Issue
Block a user