From 1ade8e175f5985402d50e37c97e14fa750760bb8 Mon Sep 17 00:00:00 2001 From: artur Date: Wed, 1 Feb 2023 16:37:17 +0300 Subject: [PATCH] Fix races where Socket is closed before Websocket is created --- src/Nostr/Connection.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Nostr/Connection.ts b/src/Nostr/Connection.ts index 060fc934..828ab3ee 100644 --- a/src/Nostr/Connection.ts +++ b/src/Nostr/Connection.ts @@ -107,6 +107,11 @@ export default class Connection { console.warn("Could not load relay information", e); } + if (this.IsClosed) { + this._UpdateState(); + return; + } + this.IsClosed = false; this.Socket = new WebSocket(this.Address); this.Socket.onopen = (e) => this.OnOpen(e);