diff --git a/src/index.ts b/src/index.ts index 6294e53..18e1bf0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -76,7 +76,7 @@ export default class HyperswarmWeb extends EventEmitter { this._activeRelay.on("close", () => { this._activeRelay = undefined; }); - } while (relays.length > 0); + } while (relays.length > 0 && !this._activeRelay); if (!this._activeRelay) { throw new Error("Failed to find an available relay");