Skip to content

Commit

Permalink
fix: fail after local relay
Browse files Browse the repository at this point in the history
  • Loading branch information
v0l committed Jun 18, 2024
1 parent 338c4eb commit 5ea7cd1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/system/src/connection-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion packages/system/src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
}

/**
Expand Down

0 comments on commit 5ea7cd1

Please sign in to comment.