diff --git a/src/index.ts b/src/index.ts index 0351918..eb5caae 100644 --- a/src/index.ts +++ b/src/index.ts @@ -118,6 +118,9 @@ export default class DHT { private async fillConnections(): Promise { let available = [...this._relays.keys()].filter(x => [...this._activeRelays.keys()].includes(x)); let relayPromises = []; + if (0 > available.length) { + return; + } while (this._activeRelays.size <= Math.min(this._maxConnections, available.length + this._activeRelays.size)) { const relayIndex = await randomNumber(0, available.length - 1);