Skip to content

Commit 173303b

Browse files
committed
fix: don't allow new connections while pool closes
This fix prevents the p2p pool from accepting or initiating new connections while it is closing or after it has closed. This prevents the possibility for race conditions which was affecting the Pool test suite.
1 parent b69717a commit 173303b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/p2p/Pool.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,10 @@ class Pool extends EventEmitter {
466466
* routine is complete
467467
*/
468468
private openPeer = async (peer: Peer, expectedNodePubKey?: string, retryConnecting = false): Promise<void> => {
469+
if (this.disconnecting || !this.connected) {
470+
// if we are disconnected or disconnecting, don't open new connections
471+
throw errors.POOL_CLOSED;
472+
}
469473
this.bindPeer(peer);
470474

471475
try {

0 commit comments

Comments
 (0)