discord-bridge: retry Matrix→Discord sends that failed before reaching Discord #65

Merged
jared merged 1 commits from discord-bridge-send-retry into main 2026-11-14 14:31:24 -05:00
Owner

On 2026-11-14 14:17 a relayed message was dropped with "⚠ Your message may not have been bridged: … net/http: TLS handshake timeout". Upstream mautrix-discord v0.7.7 sends once and never retries.

Change

  • discord-bridge/patches/0001-…patch: wraps the webhook and user-session send in lotusRetrySend. It retries only errors that happen before the request is written (DNS, dial, TLS handshake timeout, proxy connect), with backoff 2/5/10/20/30/60/60/60 s (~4 min). Retries run inline in the room's event loop, so later messages queue in order. Errors after send (read timeouts, resets, Discord 5xx/REST errors) are not retried, since webhook sends have no dedupe and could duplicate. Attachment readers are rewound between attempts. Unit tests included.
  • discord-bridge/build-patched.sh: clones the tag, applies patches, runs the tests, builds with cgo against libolm (LXC 151 has libolm3). Deploy steps in its header.
  • README: documents the patched build and that install.sh still installs stock.

Already deployed

Built with go1.26.6 and deployed to LXC 151 at 14:26 (sha256 3625c096…70d1). Stock binary kept as /opt/mautrix-discord/mautrix-discord.bak-20261114-stock-v0.7.7. The bridge reconnected to the Discord gateway within 1 s. Only the pre-existing room name/topic 403s appear in the log.

Not covered: edits, reactions, redactions.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA

On 2026-11-14 14:17 a relayed message was dropped with "⚠ Your message may not have been bridged: … net/http: TLS handshake timeout". Upstream mautrix-discord v0.7.7 sends once and never retries. ## Change - `discord-bridge/patches/0001-…patch`: wraps the webhook and user-session send in `lotusRetrySend`. It retries only errors that happen **before** the request is written (DNS, dial, TLS handshake timeout, proxy connect), with backoff 2/5/10/20/30/60/60/60 s (~4 min). Retries run inline in the room's event loop, so later messages queue in order. Errors after send (read timeouts, resets, Discord 5xx/REST errors) are not retried, since webhook sends have no dedupe and could duplicate. Attachment readers are rewound between attempts. Unit tests included. - `discord-bridge/build-patched.sh`: clones the tag, applies patches, runs the tests, builds with cgo against libolm (LXC 151 has `libolm3`). Deploy steps in its header. - README: documents the patched build and that `install.sh` still installs stock. ## Already deployed Built with go1.26.6 and deployed to LXC 151 at 14:26 (sha256 `3625c096…70d1`). Stock binary kept as `/opt/mautrix-discord/mautrix-discord.bak-20261114-stock-v0.7.7`. The bridge reconnected to the Discord gateway within 1 s. Only the pre-existing room name/topic 403s appear in the log. Not covered: edits, reactions, redactions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
jared added 1 commit 2026-11-14 14:28:25 -05:00
discord-bridge: retry Matrix→Discord sends that failed before reaching Discord
Lint / Shell (shellcheck) (push) Successful in 45s
Lint / JS (eslint) (push) Successful in 41s
Lint / No Hookshot webhook IDs in README (push) Successful in 6s
Lint / No secrets in webhook configs (push) Successful in 8s
Lint / Landing page is rendered (matrix (push) Successful in 8s
Lint / Python (ruff) (push) Successful in 6s
Lint / Secret scan (gitleaks) (push) Successful in 12s
Lint / Python deps (pip-audit) (push) Successful in 38s
Lint / Shell (shellcheck) (pull_request) Successful in 10s
Lint / JS (eslint) (pull_request) Successful in 8s
Lint / No Hookshot webhook IDs in README (pull_request) Successful in 10s
Lint / No secrets in webhook configs (pull_request) Successful in 6s
Lint / Landing page is rendered (matrix (pull_request) Successful in 7s
Lint / Python (ruff) (pull_request) Successful in 8s
Lint / Secret scan (gitleaks) (pull_request) Successful in 11s
Lint / Python deps (pip-audit) (pull_request) Successful in 31s
037b6291c9
Upstream mautrix-discord v0.7.7 sends each message once; a momentary
"net/http: TLS handshake timeout" dropped a message on 2026-11-14 with
only a "may not have been bridged" notice. Patch 0001 retries pre-send
network failures (DNS, dial, TLS handshake) with backoff (~4 min budget),
inline in the per-room loop so order is kept. Post-send failures are not
retried to avoid duplicate webhook posts.

Adds the patch, build-patched.sh (clone tag, apply, test, cgo build
against libolm) and README notes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
jared merged commit c2ffb8907d into main 2026-11-14 14:31:24 -05:00
jared deleted branch discord-bridge-send-retry 2026-11-14 14:31:24 -05:00
Sign in to join this conversation.