Skip to content

Commit

Permalink
fix(NODE-3197): revert setImmediate in waitQueue (#2802)
Browse files Browse the repository at this point in the history
A performance regression was identified in switching the connection
pool to using setImmediate instead of process.nextTick for wait
queue processing. This patch reverts that change.
  • Loading branch information
nbbeeken committed May 12, 2021
1 parent f4d40a4 commit 6c0dfef
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/cmap/connection_pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
}

this[kWaitQueue].push(waitQueueMember);
setImmediate(() => processWaitQueue(this));
process.nextTick(processWaitQueue, this);
}

/**
Expand All @@ -270,7 +270,7 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
destroyConnection(this, connection, reason);
}

setImmediate(() => processWaitQueue(this));
process.nextTick(processWaitQueue, this);
}

/**
Expand Down Expand Up @@ -440,7 +440,7 @@ function createConnection(pool: ConnectionPool, callback?: Callback<Connection>)

// otherwise add it to the pool for later acquisition, and try to process the wait queue
pool[kConnections].push(connection);
setImmediate(() => processWaitQueue(pool));
process.nextTick(processWaitQueue, pool);
});
}

Expand Down

0 comments on commit 6c0dfef

Please sign in to comment.