From 2a8565fd1e4b01990d2995c1e90d31a324cd121a Mon Sep 17 00:00:00 2001 From: Damien Arrachequesne Date: Sun, 19 Feb 2023 23:25:05 +0100 Subject: [PATCH] refactor: catch errors when trying to restore the connection state --- lib/namespace.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/namespace.ts b/lib/namespace.ts index c5658f76db..d153a0b23b 100644 --- a/lib/namespace.ts +++ b/lib/namespace.ts @@ -358,12 +358,15 @@ export class Namespace< typeof sessionId === "string" && typeof offset === "string" ) { - const session = await this.adapter.restoreSession(sessionId, offset); + let session; + try { + session = await this.adapter.restoreSession(sessionId, offset); + } catch (e) { + debug("error while restoring session: %s", e); + } if (session) { debug("connection state recovered for sid %s", session.sid); return new Socket(this, client, auth, session); - } else { - debug("unable to restore session state"); } } return new Socket(this, client, auth);