Skip to content

Behaviour for namespace connect mechanism and connect_errors #4970

Answered by darrachequesne
Totodore asked this question in Q&A
Discussion options

You must be logged in to vote

Hi!

In the official implementation, we first run all the middlewares and then the socket gets connected (your 1st solution):

socket.io/lib/namespace.ts

Lines 315 to 358 in bf64870

async _add(
client: Client<ListenEvents, EmitEvents, ServerSideEvents>,
auth: Record<string, unknown>,
fn: (
socket: Socket<ListenEvents, EmitEvents, ServerSideEvents, SocketData>
) => void
) {
debug("adding socket to nsp %s", this.name);
const socket = await this._createSocket(client, auth);
if (
// @ts-ignore
this.server.opts.connectionStateRecovery?.skipMiddlewares &&
socket.recovered &&
client.conn.readyState === "open"
) {

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Totodore
Comment options

Answer selected by Totodore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants