Skip to content

Commit c9f9d5e

Browse files
authored
fix: revert use of setImmediate to process.nextTick (#2611)
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. NODE-2861
1 parent 89b77ed commit c9f9d5e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/cmap/connection_pool.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ class ConnectionPool extends EventEmitter {
233233
}
234234

235235
this[kWaitQueue].push(waitQueueMember);
236-
setImmediate(() => processWaitQueue(this));
236+
process.nextTick(() => processWaitQueue(this));
237237
}
238238

239239
/**
@@ -258,7 +258,7 @@ class ConnectionPool extends EventEmitter {
258258
destroyConnection(this, connection, reason);
259259
}
260260

261-
setImmediate(() => processWaitQueue(this));
261+
process.nextTick(() => processWaitQueue(this));
262262
}
263263

264264
/**
@@ -428,7 +428,7 @@ function createConnection(pool, callback) {
428428

429429
// otherwise add it to the pool for later acquisition, and try to process the wait queue
430430
pool[kConnections].push(connection);
431-
setImmediate(() => processWaitQueue(pool));
431+
process.nextTick(() => processWaitQueue(pool));
432432
});
433433
}
434434

@@ -439,7 +439,7 @@ function destroyConnection(pool, connection, reason) {
439439
pool[kPermits]++;
440440

441441
// destroy the connection
442-
setImmediate(() => connection.destroy());
442+
process.nextTick(() => connection.destroy());
443443
}
444444

445445
function processWaitQueue(pool) {

0 commit comments

Comments
 (0)