fix: fail after local relay
This commit is contained in:
parent
338c4eb18a
commit
5ea7cd17d8
@ -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;
|
||||
|
@ -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");
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user