Repository navigation
feat(messages): track and surface send failures across channels - #946
Merged
Merged
Conversation
Previously an outgoing message stayed looking "sent" even when the channel API (Messenger/WhatsApp/Zalo/TikTok/Instagram/Telegram) failed to deliver it — no status was persisted and the UI showed nothing. - add nullable Message.sendError column (+ sharded schema mirror and migrations, not yet applied) - sendMessageToChannel persists the error and broadcasts a new messageFailed realtime event; clears it if a BullMQ retry later succeeds - sendFlowStepToChannel (bot/flow-originated sends) now records failures the same way as inbox-composed messages - chat-store matches messageFailed by clientId first (falls back to id) to avoid losing the error to a race with the messageCreated broadcast, and preserves it across the optimistic-message swap - message bubble shows a small icon next to outgoing failed messages; the error text only appears in a hover tooltip
viethung0o0
pushed a commit
that referenced
this pull request
Sep 7, 2026
Previously an outgoing message stayed looking "sent" even when the channel API (Messenger/WhatsApp/Zalo/TikTok/Instagram/Telegram) failed to deliver it — no status was persisted and the UI showed nothing. - add nullable Message.sendError column (+ sharded schema mirror and migrations, not yet applied) - sendMessageToChannel persists the error and broadcasts a new messageFailed realtime event; clears it if a BullMQ retry later succeeds - sendFlowStepToChannel (bot/flow-originated sends) now records failures the same way as inbox-composed messages - chat-store matches messageFailed by clientId first (falls back to id) to avoid losing the error to a race with the messageCreated broadcast, and preserves it across the optimistic-message swap - message bubble shows a small icon next to outgoing failed messages; the error text only appears in a hover tooltip Co-authored-by: Deathgiver <[email protected]>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Message.sendErrorcolumn, persists/clears it around the sharedsendMessageToChannelsend path (agent-composed and bot/flow-composed messages alike), and surfaces it in the inbox UI.messageFailedandmessageCreatedrealtime events, and bot-originated sends not being tracked at all.Changes
packages/database/src/schema/message.ts+ sharded mirror/migrations — new nullablesendErrorcolumn (migration generated, not yet applied — needs explicit approval per repo convention).packages/database/src/repositories/message/message-repository.ts+ sharded repository —updateSendErrormethod.apps/worker/src/chat/handlers/send-message.ts— persists/clearssendErroron send failure/retry-success, broadcasts a newmessageFailedrealtime event, sharedbroadcastChatEventhelper, caps error length at 500 chars.apps/worker/src/chat/handlers/send-flow-step.ts— bot/flow-originated sends now recordsendErrorthe same way as inbox-composed messages.apps/worker/src/chat/worker.ts— passesjob.attemptsMadethrough so a successful retry can clear a prior error.packages/partysocket-config/src/schemas.ts— newRealtimeEventMessageFailedevent type (clientId+ nullableerror).apps/builder/src/features/chat/store/chat-store.ts+chat-realtime.tsx—markMessageFailedmatches byclientIdfirst (falls back toid) to avoid losing the error to a race withmessageCreated; preservessendErroracross the optimistic-message swap.apps/builder/src/features/messages/components/message-item.tsx— small icon next to outgoing failed messages; error text only shown in a hover tooltip. NewsendFailedi18n key added to all 19 language files.apps/worker/__tests__/send-message-handler.test.ts— new tests for the failure/clear-on-retry paths.Test plan
pnpm --filter @chatbotx.io/database check-typespnpm --filter worker check-typespnpm --filter builder check-typespnpm lintpnpm --filter worker exec vitest run __tests__/send-message-handler.test.ts(15/15 passing)db:migrate/db:migrate-shards