[#112] Fix race condition with closing sessions

This commit is contained in:
Radon Rosborough 2021-09-18 10:28:17 -07:00
parent 3fa023285b
commit d46b86c631
1 changed files with 5 additions and 0 deletions

View File

@ -155,6 +155,11 @@ export class Session {
logError(err);
await this.teardown();
});
// User may have closed websocket before we were able to set up
// the onclose listener.
if (this.ws.readyState === WebSocket.CLOSED) {
await this.teardown();
}
} catch (err) {
logError(err);
this.sendError(err);