Fix Acknowledgment Callback Signature with ackTimeout Option #5447
+176
−30
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.
Fix Acknowledgment Callback Signature with ackTimeout Option
Description
This PR fixes an inconsistency in acknowledgment callback signatures when emitting messages with the
ackTimeoutoption set but without explicitly using.timeout().Problem
When emitting a message with an acknowledgment callback before the 'connected' event with
ackTimeoutoption configured, the callback was incorrectly receiving 2 arguments(null, response)instead of just the response. This behavior was inconsistent with messages emitted after connection, which correctly received only 1 argument.This inconsistency made it difficult to write uniform code for handling acknowledgments.
Solution
The fix ensures that:
ackTimeoutoption only affects timeout behavior, not callback signatureChanges
_registerAckCallbackto introduce ahasTimeoutattribute that differentiates between cases with explicit timeout (via.timeout()) and implicit timeout (viaackTimeoutoption)done()callback is called exactly once in async tests with multiple completion pathsBehavior After Fix
Standards Alignment
The new behavior matches the Socket.IO Acknowledgements documentation, ensuring consistent and predictable callback behavior across all scenarios.
Closes: #5446