Repository navigation
Conversation
…d without ackTimeout With the `retries` option, the queue wraps the user callback in a handler whose first argument is the error. Without `ackTimeout` (or `timeout()`), that handler was registered as-is, so it received the server response directly: `cb(42)` from the server was read as an error, the packet was sent again until the retries were exhausted, and the user callback got `42` as the error. `emitWithAck()` rejected with the response value. The queue handler is now flagged with `withError`, so the response is always prepended with `null`, like when `ackTimeout` is set. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
The kind of change this PR does introduce
Current behavior
With
retriesbut noackTimeout, the client reads the server acknowledgement as an error:_addToQueue()pushes a handler that expects the error as its first argument. Without a timeout,_registerAckCallback()stores it as-is. Soonack()does not prependnull, and the packet is re-sent until the retries run out.New behavior
The queue handler is flagged with
withError, like theemitWithAck()handler and the wrapper used when a timeout is set. The callback now gets(null, 42)and the event is sent once. On disconnection,_clearAcks()now also notifies the queue handler, as it already does withackTimeout. So a disconnection counts as one try, and the packet is still re-sent on reconnection.Other information (e.g. related issues)
No existing issue found. I added two tests in
test/retry.ts. Before the fix they fail withexpected 1 to equal null, andemitWithAck()rejects with2.I used Claude Code to write this change.