Repository navigation
fix(auto-reply): reject redeliveries without recreating drained queues - #124723
Merged
Merged
Conversation
enqueueFollowupRun called getFollowupQueue (which inserts into the process-global FOLLOWUP_QUEUES registry) before the recent-message-id dedupe peek. A provider redelivery arriving after the original queue drained and self-deleted recreated the registry entry, was rejected by the peek, and left an empty FollowupQueueState (AbortController, arrays, WeakSets) in the map forever — registry entries are only deleted when a drain finishes, and a queue with no items never drains. Long-lived gateways leaked one state object per redelivered session key. Root cause: mutation-before-validation ordering. The dedupe key derivation does not need the queue, so the peek now runs first and the registry entry is only created for admitted work. Regression: new dedupe test drains a queue to self-deletion, replays the message, and asserts no registry entry reappears — fails pre-fix.
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
steipete
marked this pull request as ready for review
August 16, 2026 18:00
Contributor
Author
|
Merged via squash.
|
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Aug 17, 2026
openclaw#124723) enqueueFollowupRun called getFollowupQueue (which inserts into the process-global FOLLOWUP_QUEUES registry) before the recent-message-id dedupe peek. A provider redelivery arriving after the original queue drained and self-deleted recreated the registry entry, was rejected by the peek, and left an empty FollowupQueueState (AbortController, arrays, WeakSets) in the map forever — registry entries are only deleted when a drain finishes, and a queue with no items never drains. Long-lived gateways leaked one state object per redelivered session key. Root cause: mutation-before-validation ordering. The dedupe key derivation does not need the queue, so the peek now runs first and the registry entry is only created for admitted work. Regression: new dedupe test drains a queue to self-deletion, replays the message, and asserts no registry entry reappears — fails pre-fix.
chovizzz
added a commit
to chovizzz/openclaw
that referenced
this pull request
Sep 2, 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.
What Problem This Solves
enqueueFollowupRuncalledgetFollowupQueue()— which inserts a newFollowupQueueStateinto the process-globalFOLLOWUP_QUEUESregistry — before the recent-message-id dedupe peek. A provider redelivery (Discord/Signal redelivering the same message id within the 5-minute dedupe TTL) arriving after the original queue had drained and self-deleted would recreate the registry entry, get rejected by the peek, and leave an emptyFollowupQueueState(AbortController, item arrays, WeakSets) in the global map forever: registry entries are only deleted when a drain finishes with no pending work, and a queue that never receives an item never drains. Long-lived gateways leaked one state object per redelivered session key.Why This Change Was Made
Root cause: mutation-before-validation ordering. The dedupe key derivation (
buildRecentMessageIdKey) only needs the run and the queue key, not the queue object, so the peek now runs first and the registry entry is created only for work that passes redelivery dedupe. One reorder, no new state or branches.User Impact
No more unbounded registry growth from provider redeliveries on long-lived gateways. No behavior change for admitted messages.
Evidence
src/auto-reply/reply/queue.dedupe.test.ts: drains a queue to registry self-deletion, replays the same message id, asserts rejection and that no registry entry reappears — fails pre-fix (entry recreated), passes post-fix.node scripts/run-vitest.mjs run src/auto-reply/reply/queue— 8 files, 32 tests pass; dedupe suite 15/15.