Skip to content

Handle message processing failures without unhandled rejections #14

Description

@cubrift

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcodexUse for codex-generated issues only.good first issueGood for newcomerswontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions