chore(inbound): drop dead outer catch on postUpsertWork
Addresses Copilot review on PR #392. Both tasks inside `postUpsertTasks` already swallow their rejections via `.catch`, so `Promise.all([taskA.catch, taskB.catch])` never rejects, and `postUpsertMutex.mutex(... postUpsertTasks)` therefore never rejects in practice. The outer `.catch` could only fire on AsyncMutex internal corruption — an extremely rare event, and one whose log message would be misleading ("background post-upsert work failed" pointing at the mutex layer, not the work). Replace with `void postUpsertWork`: marks the floating promise as intentional, and lets a truly unexpected rejection surface as an UnhandledPromiseRejection — a loud, attributable signal of a real bug rather than a swallowed warn buried in logs.
This commit is contained in:
+7
-11
@@ -1509,17 +1509,13 @@ export const makeChatsSocket = (config: SocketConfig) => {
|
||||
)
|
||||
}
|
||||
} else {
|
||||
postUpsertWork.catch(err =>
|
||||
logger?.warn(
|
||||
{
|
||||
err,
|
||||
messageId: msg.key?.id,
|
||||
remoteJid: msg.key?.remoteJid,
|
||||
shouldProcessHistoryMsg
|
||||
},
|
||||
'background post-upsert work failed'
|
||||
)
|
||||
)
|
||||
// `postUpsertWork` cannot reject in practice — both tasks inside
|
||||
// `postUpsertTasks` already swallow their rejections via `.catch`,
|
||||
// so `Promise.all` never rejects. `void` marks the floating promise
|
||||
// as intentional. If `postUpsertMutex` itself ever throws (e.g.
|
||||
// runtime corruption), the resulting unhandled rejection is the
|
||||
// signal we want — it's loud and points at a real bug.
|
||||
void postUpsertWork
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user