Repository navigation
fix: allow socketsJoin/socketsLeave/disconnectSockets to be awaited - #5581
Closed
Ankit-Silwal wants to merge 1 commit into
Closed
Ankit-Silwal wants to merge 1 commit into
Ankit-Silwal wants to merge 1 commit into
Conversation
Update the return types of addSockets, delSockets, and disconnectSockets in the base Adapter from void to void | Promise<void> so adapters (like the Redis adapter) can return Promises that resolve once all remote nodes have processed the operation. Update BroadcastOperator's socketsJoin, socketsLeave, and disconnectSockets to propagate the adapter's return value, enabling: await io.in(socketId).socketsJoin(room); This is fully backward compatible — existing code that doesn't await continues to work unchanged, while multi-server setups with async adapters can now await to ensure ordering guarantees. Related: #4734 Co-Authored-By: Claude Opus 4.6 (1M context) <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.
Summary
Adapter.addSockets,delSockets, anddisconnectSocketsreturn types fromvoidtovoid | Promise<void>BroadcastOperator.socketsJoin,socketsLeave, anddisconnectSocketsto propagate the adapter's return valueRemoteSocket.joinandleavereturn types accordinglyContext
This is the companion change for socketio/socket.io-redis-adapter#577, which makes the Redis adapter's
addSockets/delSockets/disconnectSocketsreturn Promises that resolve once all remote nodes have acknowledged the operation.Without this change, the Promise returned by the Redis adapter is silently dropped because
BroadcastOperator.socketsJoindoesn't return the adapter's result.Usage
Fully backward compatible — the return type is
void | Promise<void>, so existing code that doesn'tawaitcontinues to work unchanged.Related: #4734
Test plan
socket.io-adapterTypeScript compilation passesvoid | Promise<void>is a supertype of bothvoidandPromise<void>🤖 Generated with Claude Code