meshmonitor icon indicating copy to clipboard operation
meshmonitor copied to clipboard

[BUG] 4.14.1 - frozen/unsent messages from MC bridge

Open kokoshell opened this issue 3 months ago • 6 comments

Image

kokoshell avatar Aug 13 '26 19:08 kokoshell

Thanks for the report! Classifying this as a Bug Report.

What the screenshot shows

The ⏱ (stopwatch) icon isn't a "still sending" spinner — it's the fallback rendering in MessageStatusIndicator.tsx for any of MeshMonitor's own outbound messages whose deliveryState is stuck at pending/null for more than 30s (i.e. it never advanced to delivered/confirmed/failed). Looking at the tags (MC@...) and file, this is the Meshtastic ChannelsTab view showing MeshMonitor's own relays from the MT↔MC automation bridge (per src/components/automations/templates/bridge.ts), not a MeshCore-side view — MeshCore messages don't carry a delivery-state icon at all in this codebase.

Root cause investigation

I traced the send/ACK path:

  • The bridge sends relayed messages through the exact same sendTextMessage() path as a normal user-typed message (meshActionDeps.ts → meshtasticManager.ts) — it does not insert message rows directly or set status itself.
  • deliveryState starts as 'pending' when the message is inserted, and only a routing-layer ACK/confirmation packet (matched by requestId) flips it to delivered/confirmed. There's no background sweeper that reconciles rows stuck at pending — if the matching ACK is ever missed, the row is stuck at pending forever.
  • There is a real, narrow race window in sendTextMessage(): the outbound packet is transmitted (transport.send(...)) and logged before the message row is inserted into the DB (a few awaits later). If the radio's ACK is decoded and processed inside that window, the ACK handler looks up the row by requestId, finds nothing yet, logs "Could not find original message with requestId", and silently discards the ACK — nothing ever retries or repairs it afterward.

That race is a plausible root cause, but I want to flag a caveat rather than assume it: the conversation content in the screenshot (replies, an "ack") only proves the MeshCore side of the exchange got through — it doesn't prove the Meshtastic transmissions themselves were actually ACKed at the radio/routing layer. If the bridge is relaying many messages in quick succession, this could equally be a real missing-ACK situation (e.g. duty-cycle limiting or channel congestion on the Meshtastic side) rather than a MeshMonitor bookkeeping bug — in which case the fix would look different (rate-limiting/backoff in the bridge, not a race-condition fix).

What would help confirm this

Could you share a few more details?

  1. Does this happen on every bridged message, or only during bursts (e.g. several messages relayed back-to-back)?
  2. Does the ⏱ ever clear on its own, or does it stay stuck indefinitely until you reload the page?
  3. What's the round-trip signal quality / hop count on the Meshtastic side for the node(s) involved — any chance these transmissions genuinely never got ACKed over RF?
  4. MeshMonitor version (4.14.1 confirmed?) and whether this only started after enabling the MT↔MC bridge automation, or happens on manually-typed messages too.

If it turns out to be the insert/ACK race described above, the fix is small (reorder sendTextMessage() so the DB row exists before the packet is transmitted, or stash unmatched ACKs in a short-TTL map and apply them once the row lands) — happy to implement once we've ruled out the rate-limiting explanation.

-- Authored by Roger 🤓


Generated by Claude Code

Yeraze avatar Aug 13 '26 19:08 Yeraze

  1. it seems to happen only on MC bursts messages.
  2. in that case the clock stays stuck indefinitely until I reload the page ...
  3. it has nothing to do with RF
  4. problem is bridge only related

kokoshell avatar Aug 13 '26 19:08 kokoshell

Thanks, those answers are really useful, and #2 in particular changes where I'm looking.

Why #2 matters

My earlier theory was a race in sendTextMessage(): the packet gets transmitted before the message row is inserted, so when the ACK comes back the handler can't find the row by requestId, discards it, and nothing repairs it later.

Your answer #2 argues against that. If the ACK were being discarded, deliveryState would be stuck at pending in the database, and a page reload would just re-render the same ⏱. The fact that reloading clears it means the row was updated correctly, so the ACK did arrive and did get matched. The database is right; it's the live view that's stale.

Your answers #3 and #4 also rule out the other explanation I floated (duty-cycle / congestion causing genuinely missing ACKs over RF).

So this looks like a realtime UI update problem, not a send/ACK bookkeeping problem, which means the fix I sketched last time (reordering the send, or stashing unmatched ACKs) wouldn't have helped. Good thing we checked.

That also fits your #1: the ACK handler emits a routing:update event and the frontend responds by invalidating its cached data. Under a burst, that's N overlapping invalidations of the same cache key in quick succession, with no coalescing, a plausible place for updates to get lost in a way that a single message would never expose.

The one thing I want to confirm

My whole re-diagnosis rests on how I'm reading "stays stuck indefinitely until I reload the page", so before I chase it down the wrong path:

After you reload, does the ⏱ actually go away, and the message show as sent/delivered?

Or did you mean it stays stuck and reloading is just the only thing you can try (i.e. the ⏱ is still there afterwards)?

Those two point at completely different parts of the codebase, so it's worth being sure. If reloading does clear it, that's very strong evidence and I can go straight at the burst path.

One more thing that would help if it's easy: roughly how many messages in a burst before you see it, 2-3, or more like 10+?

-- Authored by Roger 🤓


Generated by Claude Code

Yeraze avatar Aug 13 '26 19:08 Yeraze

@kokoshell any more data here or should we close this?

Yeraze avatar Aug 25 '26 12:08 Yeraze

Any update here?

Yeraze avatar Sep 01 '26 19:09 Yeraze

Closing due to no response

Yeraze avatar Sep 02 '26 15:09 Yeraze