Commit 8372b49
[Improve] Harden the Discord gateway delivery and leadership paths (#410)
* Harden the Discord gateway delivery and leadership paths
Follow-ups from the PR #268 reliability review:
- surface the dead-letter stream: quarantine depth is tracked in gateway
status and shown as a failing diagnostic row in Discord settings, so
undeliverable events are visible instead of accumulating silently
- bound the durable streams: the inbound stream and dead-letter stream
get approximate MAXLEN caps (DISCORD_GATEWAY_INBOUND_MAX_ENTRIES,
DISCORD_GATEWAY_DEAD_LETTER_MAX_ENTRIES), and capacity pressure is
reported in status before shedding starts
- tolerate one transient Redis error on lease renewal: the 30s lease
leaves room for two 10s renew intervals, so only a definitive
ownership loss or a second consecutive failure tears down the Gateway
connection (renewDetailed distinguishes lost from error)
- restart the delivery backoff after a long healthy run instead of
ratcheting toward the lifetime maximum forever
- report supervisor death: the embedded supervisor takes an onFatal
hook, wired to Sentry in the BullMQ host, and stamps the shared
status so a silently-stopped Discord ingestion pages and shows in
diagnostics
The lease-renewal tolerance is covered indirectly (renewDetailed
contract + simple streak logic); there is no service-level harness to
drive the renew timer directly.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Address gateway review findings: attempts-hash leak and erasable pressure warning
- pruneOrphanedAttempts deletes retry counters whose stream entries were
shed by the MAXLEN cap (acknowledge/quarantine clean up their own);
runs on the status refresh timer so the attempts hash stays bounded
with the stream during a long outage
- the capacity pressure warning moves from lastError — which every
successful delivery clears — to a dedicated capacityWarning status
field whose only writer is the refresh timer, and Discord settings
shows it as an Event backlog diagnostic row
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
* Snapshot attempt counters before reading the oldest stream entry
pruneOrphanedAttempts read the stream first: an event enqueued and
attempted between XRANGE (empty) and HKEYS put a live counter in the
deletion set, resetting its retry accounting past the configured
maximum. Snapshotting the tracked ids first means a counter recorded
after the snapshot can never be pruned; ordering is covered by tests.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>1 parent c023805 commit 8372b49
15 files changed
Lines changed: 412 additions & 27 deletions
File tree
- .changeset
- apps
- bullmq/src
- discord-gateway/src
- web/src
- components/settings
- trpc/commands/comms
- packages/redis/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
78 | 91 | | |
79 | 92 | | |
80 | 93 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
7 | 9 | | |
8 | 10 | | |
9 | 11 | | |
| |||
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| 38 | + | |
| 39 | + | |
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
| |||
65 | 69 | | |
66 | 70 | | |
67 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
68 | 80 | | |
69 | 81 | | |
70 | 82 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
158 | 159 | | |
159 | 160 | | |
160 | 161 | | |
| |||
164 | 165 | | |
165 | 166 | | |
166 | 167 | | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
167 | 174 | | |
168 | 175 | | |
169 | 176 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
18 | 27 | | |
19 | 28 | | |
20 | 29 | | |
| |||
24 | 33 | | |
25 | 34 | | |
26 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
27 | 45 | | |
28 | 46 | | |
29 | 47 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments