Skip to content

Commit 6c0dfef

Browse files
authored
fix(NODE-3197): revert setImmediate in waitQueue (#2802)
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.
1 parent f4d40a4 commit 6c0dfef

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/cmap/connection_pool.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ export class ConnectionPool extends TypedEventEmitter<ConnectionPoolEvents> {
245245
}
246246

247247
this[kWaitQueue].push(waitQueueMember);
248-
setImmediate(() => processWaitQueue(this));
248+
process.nextTick(processWaitQueue, this);
249249
}
250250

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

273-
setImmediate(() => processWaitQueue(this));
273+
process.nextTick(processWaitQueue, this);
274274
}
275275

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

441441
// otherwise add it to the pool for later acquisition, and try to process the wait queue
442442
pool[kConnections].push(connection);
443-
setImmediate(() => processWaitQueue(pool));
443+
process.nextTick(processWaitQueue, pool);
444444
});
445445
}
446446

0 commit comments

Comments
 (0)