Skip to content

Commit

Permalink
refactor: catch errors when trying to restore the connection state
Browse files Browse the repository at this point in the history
  • Loading branch information
darrachequesne committed Feb 20, 2023
1 parent d0b22c6 commit 2a8565f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 2a8565f

Please sign in to comment.