fix: skip retry for expired status messages over 24 hours old

Cherry-pick from upstream PR #2280 (commit 92d4198)

- Add STATUS_EXPIRY_SECONDS constant (24h = 86400s)
- Skip retry attempts for status broadcast messages older than 24h
- Saves resources by not retrying messages that are already expired

Co-authored-by: João Lucas de Oliveira Lopes <55464917+jlucaso1@users.noreply.github.com>
This commit is contained in:
Claude
2026-01-22 18:24:18 +00:00
parent 55e86987e9
commit 9e1e67df6a
2 changed files with 16 additions and 1 deletions
+13 -1
View File
@@ -3,7 +3,7 @@ import { Boom } from '@hapi/boom'
import { randomBytes } from 'crypto'
import Long from 'long'
import { proto } from '../../WAProto/index.js'
import { DEFAULT_CACHE_TTLS, KEY_BUNDLE_TYPE, MIN_PREKEY_COUNT } from '../Defaults'
import { DEFAULT_CACHE_TTLS, KEY_BUNDLE_TYPE, MIN_PREKEY_COUNT, STATUS_EXPIRY_SECONDS } from '../Defaults'
import { metrics, recordMessageReceived, recordHistorySyncMessages, recordMessageRetry, recordMessageFailure } from '../Utils/prometheus-metrics.js'
import type {
GroupParticipant,
@@ -1299,6 +1299,18 @@ export const makeMessagesRecvSocket = (config: SocketConfig) => {
return sendMessageAck(node)
}
// Skip retry for expired status messages (>24h old)
if (isJidStatusBroadcast(msg.key.remoteJid!)) {
const messageAge = unixTimestampSeconds() - toNumber(msg.messageTimestamp)
if (messageAge > STATUS_EXPIRY_SECONDS) {
logger.debug(
{ msgId: msg.key.id, messageAge, remoteJid: msg.key.remoteJid },
'skipping retry for expired status message'
)
return sendMessageAck(node)
}
}
const errorMessage = msg?.messageStubParameters?.[0] || ''
const isPreKeyError = errorMessage.includes('PreKey')