On 2026-11-15 21:34 a 20 KB image from Lonely was dropped with read tcp …: connection reset by peer. Patch 0001 (#65) deliberately doesn't retry failures after the request was sent, because a webhook post has no dedupe. No copy of it came back into the Matrix room, which confirms Discord never posted it.
Patch 0002
While a relay send is in flight, the bridge registers a waiter for its channel (or thread). The gateway MESSAGE_CREATE handler offers every webhook message to the waiters. A match needs the same webhook ID, the same text (trimmed) and the same attachment count, created no earlier than 2 s before the send started.
On an ambiguous failure (reset, EOF, broken pipe, timeout waiting for the reply, Discord 5xx), it waits up to 6 s for the echo:
echo seen: the send is treated as successful and its Discord ID recorded, so there's no resend, no warning, and no copy back into Matrix (the portal later drops the queued MESSAGE_CREATE as a duplicate);
no echo: it retries with the 0001 backoff, and checks again without waiting before each resend in case a late echo arrived during the backoff.
User-session sends are unchanged (they still retry pre-send errors only). Discord 4xx is never retried.
7 new tests, including the waiter's matching rules. build-patched.sh now runs them with -race.
Already deployed
Clean build via build-patched.sh (both patches applied in order, tests pass with -race), deployed to LXC 151 at 21:41 (sha256 7b396eb2…7111). Reconnected to Discord immediately. The previous build is kept as /opt/mautrix-discord/mautrix-discord.bak-20261115-patch0001.
On 2026-11-15 21:34 a 20 KB image from Lonely was dropped with `read tcp …: connection reset by peer`. Patch 0001 (#65) deliberately doesn't retry failures after the request was sent, because a webhook post has no dedupe. No copy of it came back into the Matrix room, which confirms Discord never posted it.
## Patch 0002
- While a relay send is in flight, the bridge registers a waiter for its channel (or thread). The gateway MESSAGE_CREATE handler offers every webhook message to the waiters. A match needs the same webhook ID, the same text (trimmed) and the same attachment count, created no earlier than 2 s before the send started.
- On an ambiguous failure (reset, EOF, broken pipe, timeout waiting for the reply, Discord 5xx), it waits up to 6 s for the echo:
- **echo seen**: the send is treated as successful and its Discord ID recorded, so there's no resend, no warning, and no copy back into Matrix (the portal later drops the queued MESSAGE_CREATE as a duplicate);
- **no echo**: it retries with the 0001 backoff, and checks again without waiting before each resend in case a late echo arrived during the backoff.
- User-session sends are unchanged (they still retry pre-send errors only). Discord 4xx is never retried.
- 7 new tests, including the waiter's matching rules. `build-patched.sh` now runs them with `-race`.
## Already deployed
Clean build via `build-patched.sh` (both patches applied in order, tests pass with `-race`), deployed to LXC 151 at 21:41 (sha256 `7b396eb2…7111`). Reconnected to Discord immediately. The previous build is kept as `/opt/mautrix-discord/mautrix-discord.bak-20261115-patch0001`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
On 2026-11-15 21:34 an image relay failed with "read: connection reset by
peer" after the request was sent. Patch 0001 deliberately doesn't retry
those (a webhook post has no dedupe), so the image was dropped.
Patch 0002: while a relay send is in flight the bridge watches the
Discord gateway for its own post (same webhook, text and attachment
count, created after the send started). On an ambiguous failure (reset,
EOF, timeout waiting for the reply, Discord 5xx) it waits up to 6 s for
that echo: if it shows up the send counts as delivered and is recorded
(no resend, no copy back into Matrix); otherwise it retries with the
0001 backoff, checking again before each resend.
build-patched.sh runs the new tests with -race.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA
jared
scheduled this pull request to auto merge when all checks succeed 2026-11-15 21:46:30 -05:00
jared
merged commit b3fec4af2a into main2026-11-15 21:46:31 -05:00
jared
deleted branch discord-bridge-echo-check2026-11-15 21:46:31 -05:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
On 2026-11-15 21:34 a 20 KB image from Lonely was dropped with
read tcp …: connection reset by peer. Patch 0001 (#65) deliberately doesn't retry failures after the request was sent, because a webhook post has no dedupe. No copy of it came back into the Matrix room, which confirms Discord never posted it.Patch 0002
build-patched.shnow runs them with-race.Already deployed
Clean build via
build-patched.sh(both patches applied in order, tests pass with-race), deployed to LXC 151 at 21:41 (sha2567b396eb2…7111). Reconnected to Discord immediately. The previous build is kept as/opt/mautrix-discord/mautrix-discord.bak-20261115-patch0001.🤖 Generated with Claude Code
https://claude.ai/code/session_01PPmy3tPq869XDW4njjVaKA