Skip to content

Commit e6fdf38

Browse files
fixed wait queue test
1 parent 13a8a25 commit e6fdf38

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

test/integration/node-specific/client_close.test.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -357,36 +357,34 @@ describe.skip('MongoClient.close() Integration', () => {
357357
});
358358

359359
it('the wait queue timer is cleaned up by client.close()', async function () {
360-
const run = async function ({ MongoClient, uri, expect, sleep, getTimerCount }) {
360+
const run = async function ({ MongoClient, uri, expect, getTimerCount, once }) {
361361
const waitQueueTimeoutMS = 1515;
362362

363363
const client = new MongoClient(uri, {
364364
maxPoolSize: 1,
365365
waitQueueTimeoutMS,
366-
appName: 'waitQueueTestClient'
366+
appName: 'waitQueueTestClient',
367+
monitorCommands: true
367368
});
368-
const insertPromise = client
369+
client
369370
.db('db')
370371
.collection('collection')
371372
.insertOne({ x: 1 })
372373
.catch(e => e);
373-
await client.once('commandStarted', v => v);
374+
await once(client, 'connectionCheckedOut');
374375

375-
client
376+
const blockedInsert = client
376377
.db('db')
377378
.collection('collection')
378379
.insertOne({ x: 1 })
379380
.catch(e => e);
380-
await client.once('commandStarted', v => v);
381-
382-
// don't allow entire checkout timer to elapse to ensure close is called mid-timeout
383-
await sleep(waitQueueTimeoutMS / 2);
381+
await once(client, 'connectionCheckOutStarted');
384382

385383
expect(getTimerCount()).to.not.equal(0);
386384
await client.close();
387385
expect(getTimerCount()).to.equal(0);
388386

389-
const err = await insertPromise;
387+
const err = await blockedInsert;
390388
expect(err).to.be.instanceOf(Error);
391389
expect(err.message).to.contain(
392390
'Timed out while checking out a connection from connection pool'

timer-check-out.logs.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{"error":{"message":"Process timed out: resources remain in the event loop","resources":{"libuvResources":[{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x0000000109d0d9f0","localEndpoint":{"host":"localhost","port":49710},"remoteEndpoint":{"host":"localhost","port":31000},"sendBufferSize":146808,"recvBufferSize":406960,"fd":18,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x00000001247078e0","localEndpoint":{"host":"localhost","port":49712},"remoteEndpoint":{"host":"localhost","port":31001},"sendBufferSize":146808,"recvBufferSize":406984,"fd":19,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x0000000109f04120","localEndpoint":{"host":"localhost","port":49711},"remoteEndpoint":{"host":"localhost","port":31002},"sendBufferSize":146808,"recvBufferSize":406984,"fd":20,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x0000000109f04590","localEndpoint":{"host":"localhost","port":49713},"remoteEndpoint":{"host":"localhost","port":31003},"sendBufferSize":146808,"recvBufferSize":407095,"fd":21,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x0000000109f04ea0","localEndpoint":{"host":"localhost","port":49714},"remoteEndpoint":{"host":"localhost","port":31000},"sendBufferSize":146808,"recvBufferSize":406227,"fd":22,"writeQueueSize":0,"readable":true,"writable":true}],"activeResources":["TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","Timeout","Timeout","Timeout","Timeout"]}}}
2+
{"error":{"message":"Process timed out: resources remain in the event loop","resources":{"libuvResources":[{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x000000011de3b8c0","localEndpoint":{"host":"localhost","port":49755},"remoteEndpoint":{"host":"localhost","port":31000},"sendBufferSize":146808,"recvBufferSize":406960,"fd":18,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x000000011df52510","localEndpoint":{"host":"localhost","port":49756},"remoteEndpoint":{"host":"localhost","port":31001},"sendBufferSize":146808,"recvBufferSize":406984,"fd":21,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x000000011df50b20","localEndpoint":{"host":"localhost","port":49757},"remoteEndpoint":{"host":"localhost","port":31002},"sendBufferSize":146808,"recvBufferSize":406984,"fd":19,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x000000011df50f30","localEndpoint":{"host":"localhost","port":49758},"remoteEndpoint":{"host":"localhost","port":31003},"sendBufferSize":146808,"recvBufferSize":407095,"fd":20,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x000000011df529d0","localEndpoint":{"host":"localhost","port":49759},"remoteEndpoint":{"host":"localhost","port":31000},"sendBufferSize":146808,"recvBufferSize":406227,"fd":22,"writeQueueSize":0,"readable":true,"writable":true}],"activeResources":["TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","Timeout","Timeout","Timeout","Timeout"]}}}
3+
{"error":{"message":"Process timed out: resources remain in the event loop","resources":{"libuvResources":[{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x0000000106a0a920","localEndpoint":{"host":"localhost","port":49791},"remoteEndpoint":{"host":"localhost","port":31000},"sendBufferSize":146808,"recvBufferSize":406960,"fd":18,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x0000000147f0e7e0","localEndpoint":{"host":"localhost","port":49792},"remoteEndpoint":{"host":"localhost","port":31001},"sendBufferSize":146808,"recvBufferSize":406984,"fd":20,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x0000000147f0eba0","localEndpoint":{"host":"localhost","port":49793},"remoteEndpoint":{"host":"localhost","port":31002},"sendBufferSize":146808,"recvBufferSize":406984,"fd":19,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x0000000147f0f050","localEndpoint":{"host":"localhost","port":49794},"remoteEndpoint":{"host":"localhost","port":31003},"sendBufferSize":146808,"recvBufferSize":407095,"fd":21,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x0000000147f0f6a0","localEndpoint":{"host":"localhost","port":49795},"remoteEndpoint":{"host":"localhost","port":31000},"sendBufferSize":146808,"recvBufferSize":406227,"fd":22,"writeQueueSize":0,"readable":true,"writable":true}],"activeResources":["TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","Timeout","Timeout","Timeout","Timeout"]}}}
4+
{"newResources":{"libuvResources":[{"type":"tcp","is_active":false,"is_referenced":true,"address":"0x0000000156f19ae0","localEndpoint":null,"remoteEndpoint":null,"sendBufferSize":0,"recvBufferSize":0,"writeQueueSize":0,"readable":false,"writable":false},{"type":"tcp","is_active":false,"is_referenced":true,"address":"0x0000000136e09c70","localEndpoint":null,"remoteEndpoint":null,"sendBufferSize":0,"recvBufferSize":0,"writeQueueSize":0,"readable":false,"writable":false},{"type":"tcp","is_active":false,"is_referenced":true,"address":"0x0000000136e0a050","localEndpoint":null,"remoteEndpoint":null,"sendBufferSize":0,"recvBufferSize":0,"writeQueueSize":0,"readable":false,"writable":false},{"type":"tcp","is_active":false,"is_referenced":true,"address":"0x0000000136e0bed0","localEndpoint":null,"remoteEndpoint":null,"sendBufferSize":0,"recvBufferSize":0,"writeQueueSize":0,"readable":false,"writable":false},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x0000000156f1bbc0","localEndpoint":{"host":"localhost","port":49838},"remoteEndpoint":{"host":"localhost","port":31000},"sendBufferSize":146808,"recvBufferSize":406457,"fd":19,"writeQueueSize":0,"readable":true,"writable":true}],"activeResources":["TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap"]}}
5+
{"beforeExitHappened":true}
6+
{"error":{"message":"Process timed out: resources remain in the event loop","resources":{"libuvResources":[{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x000000011a110810","localEndpoint":{"host":"localhost","port":49859},"remoteEndpoint":{"host":"localhost","port":31000},"sendBufferSize":146808,"recvBufferSize":406960,"fd":18,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x000000011a112b40","localEndpoint":{"host":"localhost","port":49861},"remoteEndpoint":{"host":"localhost","port":31001},"sendBufferSize":146808,"recvBufferSize":406984,"fd":23,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x000000011a112f30","localEndpoint":{"host":"localhost","port":49860},"remoteEndpoint":{"host":"localhost","port":31002},"sendBufferSize":146808,"recvBufferSize":406984,"fd":22,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x000000011a113340","localEndpoint":{"host":"localhost","port":49863},"remoteEndpoint":{"host":"localhost","port":31003},"sendBufferSize":146808,"recvBufferSize":407095,"fd":20,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x000000011a113990","localEndpoint":{"host":"localhost","port":49862},"remoteEndpoint":{"host":"localhost","port":31000},"sendBufferSize":146808,"recvBufferSize":406227,"fd":19,"writeQueueSize":0,"readable":true,"writable":true}],"activeResources":["TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","Timeout","Timeout","Timeout","Timeout"]}}}
7+
{"newResources":{"libuvResources":[{"type":"tcp","is_active":false,"is_referenced":true,"address":"0x000000012a607c60","localEndpoint":null,"remoteEndpoint":null,"sendBufferSize":0,"recvBufferSize":0,"writeQueueSize":0,"readable":false,"writable":false},{"type":"tcp","is_active":false,"is_referenced":true,"address":"0x000000013c1051c0","localEndpoint":null,"remoteEndpoint":null,"sendBufferSize":0,"recvBufferSize":0,"writeQueueSize":0,"readable":false,"writable":false},{"type":"tcp","is_active":false,"is_referenced":true,"address":"0x000000013c1055d0","localEndpoint":null,"remoteEndpoint":null,"sendBufferSize":0,"recvBufferSize":0,"writeQueueSize":0,"readable":false,"writable":false},{"type":"tcp","is_active":false,"is_referenced":true,"address":"0x000000013c107be0","localEndpoint":null,"remoteEndpoint":null,"sendBufferSize":0,"recvBufferSize":0,"writeQueueSize":0,"readable":false,"writable":false},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x000000013c108330","localEndpoint":{"host":"localhost","port":49987},"remoteEndpoint":{"host":"localhost","port":31000},"sendBufferSize":146808,"recvBufferSize":406457,"fd":20,"writeQueueSize":0,"readable":true,"writable":true}],"activeResources":["TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap"]}}
8+
{"beforeExitHappened":true}
9+
{"error":{"message":"Process timed out: resources remain in the event loop","resources":{"libuvResources":[{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x000000014af4f200","localEndpoint":{"host":"localhost","port":50084},"remoteEndpoint":{"host":"localhost","port":31000},"sendBufferSize":146808,"recvBufferSize":406960,"fd":18,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x000000014af51990","localEndpoint":{"host":"localhost","port":50086},"remoteEndpoint":{"host":"localhost","port":31001},"sendBufferSize":146808,"recvBufferSize":406984,"fd":20,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x000000014af4d2e0","localEndpoint":{"host":"localhost","port":50085},"remoteEndpoint":{"host":"localhost","port":31002},"sendBufferSize":146808,"recvBufferSize":406984,"fd":19,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x000000014af4d740","localEndpoint":{"host":"localhost","port":50087},"remoteEndpoint":{"host":"localhost","port":31003},"sendBufferSize":146808,"recvBufferSize":407095,"fd":21,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x000000014af4eae0","localEndpoint":{"host":"localhost","port":50088},"remoteEndpoint":{"host":"localhost","port":31000},"sendBufferSize":146808,"recvBufferSize":406227,"fd":22,"writeQueueSize":0,"readable":true,"writable":true}],"activeResources":["TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","Timeout","Timeout","Timeout","Timeout"]}}}
10+
{"error":{"message":"expected { acknowledged: true, …(1) } to be an instance of Error","stack":"AssertionError: expected { acknowledged: true, …(1) } to be an instance of Error\n at func (/Users/aditi.khare/Desktop/node-mongodb-native/timer-check-out.cjs:30:51)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async main (/Users/aditi.khare/Desktop/node-mongodb-native/timer-check-out.cjs:141:3)","resources":{"libuvResources":[{"type":"tcp","is_active":false,"is_referenced":true,"address":"0x0000000143f50cb0","localEndpoint":null,"remoteEndpoint":null,"sendBufferSize":0,"recvBufferSize":0,"writeQueueSize":0,"readable":false,"writable":false}],"activeResources":["TCPSocketWrap"]}}}
11+
{"newResources":{"libuvResources":[{"type":"tcp","is_active":false,"is_referenced":true,"address":"0x000000012d6233e0","localEndpoint":null,"remoteEndpoint":null,"sendBufferSize":0,"recvBufferSize":0,"writeQueueSize":0,"readable":false,"writable":false},{"type":"tcp","is_active":false,"is_referenced":true,"address":"0x000000012d6249c0","localEndpoint":null,"remoteEndpoint":null,"sendBufferSize":0,"recvBufferSize":0,"writeQueueSize":0,"readable":false,"writable":false},{"type":"tcp","is_active":false,"is_referenced":true,"address":"0x000000012d624df0","localEndpoint":null,"remoteEndpoint":null,"sendBufferSize":0,"recvBufferSize":0,"writeQueueSize":0,"readable":false,"writable":false},{"type":"tcp","is_active":false,"is_referenced":true,"address":"0x000000012d625200","localEndpoint":null,"remoteEndpoint":null,"sendBufferSize":0,"recvBufferSize":0,"writeQueueSize":0,"readable":false,"writable":false},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x000000012d6258f0","localEndpoint":{"host":"localhost","port":50144},"remoteEndpoint":{"host":"localhost","port":31000},"sendBufferSize":146808,"recvBufferSize":406457,"fd":22,"writeQueueSize":0,"readable":true,"writable":true}],"activeResources":["TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap"]}}
12+
{"beforeExitHappened":true}
13+
{"newResources":{"libuvResources":[{"type":"tcp","is_active":false,"is_referenced":true,"address":"0x0000000126865490","localEndpoint":null,"remoteEndpoint":null,"sendBufferSize":0,"recvBufferSize":0,"writeQueueSize":0,"readable":false,"writable":false},{"type":"tcp","is_active":false,"is_referenced":true,"address":"0x00000001268675e0","localEndpoint":null,"remoteEndpoint":null,"sendBufferSize":0,"recvBufferSize":0,"writeQueueSize":0,"readable":false,"writable":false},{"type":"tcp","is_active":false,"is_referenced":true,"address":"0x0000000126867850","localEndpoint":null,"remoteEndpoint":null,"sendBufferSize":0,"recvBufferSize":0,"writeQueueSize":0,"readable":false,"writable":false},{"type":"tcp","is_active":false,"is_referenced":true,"address":"0x0000000126867c00","localEndpoint":null,"remoteEndpoint":null,"sendBufferSize":0,"recvBufferSize":0,"writeQueueSize":0,"readable":false,"writable":false},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x0000000126868250","localEndpoint":{"host":"localhost","port":50441},"remoteEndpoint":{"host":"localhost","port":31000},"sendBufferSize":146808,"recvBufferSize":406457,"fd":22,"writeQueueSize":0,"readable":true,"writable":true}],"activeResources":["TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap"]}}
14+
{"beforeExitHappened":true}
15+
{"newResources":{"libuvResources":[{"type":"tcp","is_active":false,"is_referenced":true,"address":"0x000000014c70de10","localEndpoint":null,"remoteEndpoint":null,"sendBufferSize":0,"recvBufferSize":0,"writeQueueSize":0,"readable":false,"writable":false},{"type":"tcp","is_active":false,"is_referenced":true,"address":"0x000000012c61e020","localEndpoint":null,"remoteEndpoint":null,"sendBufferSize":0,"recvBufferSize":0,"writeQueueSize":0,"readable":false,"writable":false},{"type":"tcp","is_active":false,"is_referenced":true,"address":"0x000000012c61e3e0","localEndpoint":null,"remoteEndpoint":null,"sendBufferSize":0,"recvBufferSize":0,"writeQueueSize":0,"readable":false,"writable":false},{"type":"tcp","is_active":false,"is_referenced":true,"address":"0x000000012c61e7f0","localEndpoint":null,"remoteEndpoint":null,"sendBufferSize":0,"recvBufferSize":0,"writeQueueSize":0,"readable":false,"writable":false},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x000000012c61f260","localEndpoint":{"host":"localhost","port":50460},"remoteEndpoint":{"host":"localhost","port":31000},"sendBufferSize":146808,"recvBufferSize":406457,"fd":22,"writeQueueSize":0,"readable":true,"writable":true}],"activeResources":["TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap"]}}
16+
{"beforeExitHappened":true}

0 commit comments

Comments
 (0)