fix: add timeout and close handling to connection.ready()#253
Merged
ShogunPanda merged 6 commits intoplatformatic:mainfrom Mar 18, 2026
Merged
fix: add timeout and close handling to connection.ready()#253ShogunPanda merged 6 commits intoplatformatic:mainfrom
ShogunPanda merged 6 commits intoplatformatic:mainfrom
Conversation
If neither 'connect' nor 'error' fires while waiting in ready(), the callback never completes, causing pool.get() and kPerformWithRetry to hang indefinitely. This adds a timeout using the existing connectTimeout option and also listens for 'close' events. Signed-off-by: Tristan Burch <tristan@day.ai>
- Use host:port in timeout message when available for consistency with socket timeout - Destroy socket when ready() timeout fires to prevent racing socket timeout from emitting an unhandled error event after listeners are cleaned up - Skip timeout callback when connection is already in ERROR/CLOSED state to prevent double-invocation when connect() throws synchronously (e.g. invalid port) Signed-off-by: Tristan Burch <tristan@tburch.com> Signed-off-by: Tristan Burch <tristan@day.ai>
ShogunPanda
requested changes
Mar 17, 2026
Contributor
ShogunPanda
left a comment
There was a problem hiding this comment.
Can you please add a test? The rest LGTM.
Signed-off-by: Tristan Burch <tristan@day.ai>
Signed-off-by: Tristan Burch <tristan@day.ai>
When leaveGroup() is called during the metadata-insync phase of a rebalance, the metadata callback in #updateAssignments() continued unconditionally and overwrote assignments. Add a #membershipActive guard consistent with #performJoinGroup() and #performSyncGroup(). Signed-off-by: Tristan Burch <tristan@day.ai>
ShogunPanda
approved these changes
Mar 18, 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.
Summary
connection.ready()registers.once('connect')and.once('error')but if neither event fires, the callback never completes — causingpool.get()andkPerformWithRetryto hang indefinitelyconnectTimeoutoption (default 5s) so the callback is invoked with aTimeoutErrorif the connection doesn't become ready in time'close'events, returning aNetworkErrorif the connection closes while waitingcleanup()function prevents listener and timer leaks across all exit paths