Problem
The messages.upsert handler in index.js calls messageAI(sock, msg, polls) without awaiting it or attaching a per-message rejection handler. Because messageAI is asynchronous, the surrounding try/catch cannot catch failures from that promise. A failed message can therefore appear only as a generic process-level unhandled rejection.
Expected behavior
Each message-processing failure should be logged with enough context to diagnose it, while the rest of a batch continues to be processed.
Suggested direction
Keep message handling asynchronous if desired, but explicitly handle the returned promise for each message. Avoid changing the behavior so that one slow message unnecessarily blocks unrelated messages.
Acceptance criteria
- Rejected
messageAI promises are handled by the message upsert path.
- A failure includes the relevant chat or message identifier in the log.
- One failed message does not prevent other messages in the same notification batch from being attempted.
- The global unhandled rejection handler is not needed for ordinary message-processing failures.
Problem
The
messages.upserthandler inindex.jscallsmessageAI(sock, msg, polls)without awaiting it or attaching a per-message rejection handler. BecausemessageAIis asynchronous, the surroundingtry/catchcannot catch failures from that promise. A failed message can therefore appear only as a generic process-level unhandled rejection.Expected behavior
Each message-processing failure should be logged with enough context to diagnose it, while the rest of a batch continues to be processed.
Suggested direction
Keep message handling asynchronous if desired, but explicitly handle the returned promise for each message. Avoid changing the behavior so that one slow message unnecessarily blocks unrelated messages.
Acceptance criteria
messageAIpromises are handled by the message upsert path.