Repository navigation
[Fix] Discord recovery can skip events after a session is replaced - #3484
Closed
roomote-roomote[bot] wants to merge 2 commits into
Closed
roomote-roomote[bot] wants to merge 2 commits into
roomote-roomote[bot] wants to merge 2 commits into
Conversation
Contributor
|
No code issues found. See task Reviewed the checkpoint session fencing and regression tests, plus all newly pushed changes through Reviewed c9b8f14 |
roomote-roomote
Bot
requested review from
brunobergher,
daniel-lxs and
mrubens
as code owners
October 15, 2026 05:27
This was referenced Oct 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue
Internal maintainer-requested reliability work; no issue opened.
Why this PR exists
A slow checkpoint write from an invalidated Discord gateway session can overwrite its replacement session's recovery position. The new connection may then resume past events it has not durably queued.
What changed
Gateway checkpoint writes now carry their originating session ID, and PostgreSQL updates only the matching session. Flush completion and retry bookkeeping also ignore work whose session has been replaced. Ordinary acknowledged-only checkpoint coalescing, handoff and same-session retry remain intact. This adds one internal write argument and identity comparisons; no schema, dependency or UI changes. The gateway test command now loads
.env.testand uses the existing shared database lifecycle so the new persistence regression runs through the normal package command.How it was tested
50a58ed4, delayed an old checkpoint at sequence 11, saved a replacement at sequence 0, then released the old write. Both PostgreSQL and the actual gateway store incorrectly reported the replacement at 11.c9b8f141d58e7e7125f2f2d9b7e41a523ef947cc: normalpnpm --filter @roomote/discord-gateway test --runpasses all 91 tests, six SDK persistence DB tests pass, affected typechecks and gateway build pass, and full pre-push gates pass. Test database cleanup readback finds zero fixture rows.c9b8f141preserves 0 and advances to 1 only after the replacement's own acknowledgement. Scoped cleanup left zero rows.Checklist
[Fix],[Feat],[Improve],[Refactor],[Docs], or[Chore]followed by a user-facing descriptionpnpm lintandpnpm check-typespass locallypnpm changesetRelated PRs