From 822247e1fab1bc837ae640498cecd70e523f681d Mon Sep 17 00:00:00 2001 From: Liran Cohen Date: Mon, 23 Jan 2023 13:52:32 -0500 Subject: [PATCH] remove timeout on connection open --- src/Nostr/Connection.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Nostr/Connection.ts b/src/Nostr/Connection.ts index 9f810562..cb90b23c 100644 --- a/src/Nostr/Connection.ts +++ b/src/Nostr/Connection.ts @@ -126,12 +126,8 @@ export default class Connection { OnOpen(e: Event) { this.ConnectTimeout = DefaultConnectTimeout; + this._InitSubscriptions(); console.log(`[${this.Address}] Open!`); - setTimeout(() => { - if(this.Authed || this.AwaitingAuth.size === 0) { - this._InitSubscriptions(); - } - }, 150) } OnClose(e: CloseEvent) { @@ -349,6 +345,10 @@ export default class Connection { } _SendJson(obj: any) { + if(!this.Authed && this.AwaitingAuth.size > 0) { + this.Pending.push(obj); + return; + } if (this.Socket?.readyState !== WebSocket.OPEN) { this.Pending.push(obj); return; @@ -456,4 +456,4 @@ export default class Connection { } return ev; } -} \ No newline at end of file +}