fix(mothership): keep a failed direct send ahead of follow-ups queued during its POST

Merged
WA
13d ago
+65-1

Summary

  • A failed direct send goes back to the head of the queue. When a direct send's POST failed (offline, a network blip, or a busy refusal), the message was re-queued at the tail, behind any follow-up typed while that POST was out. The queue became [B, A], and the drain could send the follow-up before the message written first.
  • Why the head is right: a direct send only goes out when nothing is queued ahead of it (shouldQueueOutgoingMessage), so anything queued while its POST was out was written after it. It now goes back with insertAt(…, 0).
  • Why tests missed it: every existing direct-send test sent its follow-up only after the first send had resolved, so a follow-up never queued during the POST.

Type of Change

  • Bug fix

Testing

  • keeps a failed direct send ahead of a follow-up queued during its POST, for offline, an online network blip, and a busy 409. Each fails on staging: the follow-up is sent ahead of the first message.
  • The full gate and integration tests ran on the CI runner.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)