fix: fail after local relay
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
kieran 2024-06-18 12:05:28 +01:00
parent 338c4eb18a
commit 5ea7cd17d8
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
2 changed files with 6 additions and 1 deletions

View File

@ -13,6 +13,7 @@ import { ConnectionSyncModule, DefaultSyncModule } from "./sync/connection";
export interface ConnectionTypeEvents {
change: () => void;
connected: (wasReconnect: boolean) => void;
error: () => void;
event: (sub: string, e: TaggedNostrEvent) => void;
eose: (sub: string) => void;
closed: (sub: string, reason: string) => void;

View File

@ -150,7 +150,10 @@ export class Connection extends EventEmitter<ConnectionTypeEvents> implements Co
this.Socket.onerror = e => this.#onError(e);
this.Socket.onclose = e => this.#onClose(e);
if (awaitOpen) {
await new Promise(resolve => this.once("connected", resolve));
await new Promise((resolve, reject) => {
this.once("connected", resolve);
this.once("error", reject);
});
}
} catch (e) {
this.#connectStarted = false;
@ -276,6 +279,7 @@ export class Connection extends EventEmitter<ConnectionTypeEvents> implements Co
#onError(e: WebSocket.Event) {
this.#log("Error: %O", e);
this.emit("change");
this.emit("error");
}
/**