From 9ec5b00f290aa14e57fc116484ac63612492a7a5 Mon Sep 17 00:00:00 2001 From: Aditi Khare Date: Fri, 3 Jan 2025 11:08:47 -0500 Subject: [PATCH] temp --- socket-connection-monitoring.logs.txt | 30 ++++++++ .../node-specific/client_close.test.ts | 73 ++++++++++--------- 2 files changed, 69 insertions(+), 34 deletions(-) create mode 100644 socket-connection-monitoring.logs.txt diff --git a/socket-connection-monitoring.logs.txt b/socket-connection-monitoring.logs.txt new file mode 100644 index 0000000000..9cd5a20717 --- /dev/null +++ b/socket-connection-monitoring.logs.txt @@ -0,0 +1,30 @@ + +{} +{"relevantHostAddresses":[{"host":"localhost","port":31000},{"host":"localhost","port":31000}]} +{} +{"relevantHostAddresses":[{"host":"localhost","port":31001}]} +{} +{"relevantHostAddresses":[{"host":"localhost","port":31002}]} +{} +{"relevantHostAddresses":[{"host":"localhost","port":31003}]} +{"beforeExitHappened":true} +{"error":{"message":"Converting circular structure to JSON\n --> starting at object with constructor 'MongoClient'\n | property 's' -> object with constructor 'Object'\n | property 'sessionPool' -> object with constructor 'ServerSessionPool'\n --- property 'client' closes the circle","stack":"TypeError: Converting circular structure to JSON\n --> starting at object with constructor 'MongoClient'\n | property 's' -> object with constructor 'Object'\n | property 'sessionPool' -> object with constructor 'ServerSessionPool'\n --- property 'client' closes the circle\n at JSON.stringify ()\n at log (/Users/aditi.khare/Desktop/node-mongodb-native/socket-connection-monitoring.cjs:112:29)\n at run (/Users/aditi.khare/Desktop/node-mongodb-native/socket-connection-monitoring.cjs:20:37)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async main (/Users/aditi.khare/Desktop/node-mongodb-native/socket-connection-monitoring.cjs:121:3)","resources":{"libuvResources":[{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x000000012981e920","localEndpoint":{"host":"localhost","port":64049},"remoteEndpoint":{"host":"localhost","port":31000},"sendBufferSize":146808,"recvBufferSize":406960,"fd":24,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x0000000129820140","localEndpoint":{"host":"localhost","port":64050},"remoteEndpoint":{"host":"localhost","port":31001},"sendBufferSize":146808,"recvBufferSize":406984,"fd":25,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x0000000129820550","localEndpoint":{"host":"localhost","port":64051},"remoteEndpoint":{"host":"localhost","port":31002},"sendBufferSize":146808,"recvBufferSize":406984,"fd":26,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x0000000129820a20","localEndpoint":{"host":"localhost","port":64052},"remoteEndpoint":{"host":"localhost","port":31003},"sendBufferSize":146808,"recvBufferSize":407095,"fd":27,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x0000000129820ef0","localEndpoint":{"host":"localhost","port":64053},"remoteEndpoint":{"host":"localhost","port":31000},"sendBufferSize":146808,"recvBufferSize":406294,"fd":28,"writeQueueSize":0,"readable":true,"writable":true}],"activeResources":["TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","Timeout","Timeout","Timeout","Timeout"]}}} +{"error":{"message":"Converting circular structure to JSON\n --> starting at object with constructor 'MongoClient'\n | property 's' -> object with constructor 'Object'\n | property 'sessionPool' -> object with constructor 'ServerSessionPool'\n --- property 'client' closes the circle","stack":"TypeError: Converting circular structure to JSON\n --> starting at object with constructor 'MongoClient'\n | property 's' -> object with constructor 'Object'\n | property 'sessionPool' -> object with constructor 'ServerSessionPool'\n --- property 'client' closes the circle\n at JSON.stringify ()\n at log (/Users/aditi.khare/Desktop/node-mongodb-native/socket-connection-monitoring.cjs:112:29)\n at run (/Users/aditi.khare/Desktop/node-mongodb-native/socket-connection-monitoring.cjs:20:37)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async main (/Users/aditi.khare/Desktop/node-mongodb-native/socket-connection-monitoring.cjs:121:3)","resources":{"libuvResources":[{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x0000000106e1bb10","localEndpoint":{"host":"localhost","port":64068},"remoteEndpoint":{"host":"localhost","port":31000},"sendBufferSize":146808,"recvBufferSize":406960,"fd":24,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x0000000106e1fd30","localEndpoint":{"host":"localhost","port":64069},"remoteEndpoint":{"host":"localhost","port":31001},"sendBufferSize":146808,"recvBufferSize":406984,"fd":27,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x0000000106e20070","localEndpoint":{"host":"localhost","port":64070},"remoteEndpoint":{"host":"localhost","port":31002},"sendBufferSize":146808,"recvBufferSize":406984,"fd":28,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x0000000106e20540","localEndpoint":{"host":"localhost","port":64071},"remoteEndpoint":{"host":"localhost","port":31003},"sendBufferSize":146808,"recvBufferSize":407095,"fd":26,"writeQueueSize":0,"readable":true,"writable":true},{"type":"tcp","is_active":true,"is_referenced":true,"address":"0x0000000106e20a10","localEndpoint":{"host":"localhost","port":64072},"remoteEndpoint":{"host":"localhost","port":31000},"sendBufferSize":146808,"recvBufferSize":406294,"fd":25,"writeQueueSize":0,"readable":true,"writable":true}],"activeResources":["TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","TCPSocketWrap","Timeout","Timeout","Timeout","Timeout"]}}} +{"server":"[\n 'localhost:31000',\n Server {\n _events: [Object: null prototype] {\n serverHeartbeatStarted: [Function (anonymous)],\n serverHeartbeatSucceeded: [Function (anonymous)],\n serverHeartbeatFailed: [Function (anonymous)],\n commandStarted: [Function (anonymous)],\n commandSucceeded: [Function (anonymous)],\n commandFailed: [Function (anonymous)],\n connectionPoolCreated: [Function (anonymous)],\n connectionPoolReady: [Function (anonymous)],\n connectionPoolCleared: [Function (anonymous)],\n connectionPoolClosed: [Function (anonymous)],\n connectionCreated: [Function (anonymous)],\n connectionReady: [Function (anonymous)],\n connectionClosed: [Function (anonymous)],\n connectionCheckOutStarted: [Function (anonymous)],\n connectionCheckOutFailed: [Function (anonymous)],\n connectionCheckedOut: [Function (anonymous)],\n connectionCheckedIn: [Function (anonymous)],\n descriptionReceived: [Function (anonymous)]\n },\n _eventsCount: 18,\n _maxListeners: undefined,\n serverApi: undefined,\n topology: Topology {\n _events: [Object: null prototype],\n _eventsCount: 26,\n _maxListeners: undefined,\n client: [MongoClient],\n waitQueue: [List],\n s: [Object],\n mongoLogger: undefined,\n component: 'topology',\n connectionLock: undefined,\n [Symbol(kCapture)]: false\n },\n pool: ConnectionPool {\n _events: [Object: null prototype],\n _eventsCount: 15,\n _maxListeners: undefined,\n options: [Object],\n poolState: 'ready',\n server: [Circular *1],\n connections: [List],\n pending: 0,\n checkedOut: Set(0) {},\n minPoolSizeTimer: undefined,\n generation: 0,\n serviceGenerations: Map(0) {},\n connectionCounter: Object [Generator] {},\n cancellationToken: [CancellationToken],\n waitQueue: [List],\n metrics: [ConnectionPoolMetrics],\n processingWaitQueue: false,\n mongoLogger: undefined,\n component: 'connection',\n [Symbol(kCapture)]: false\n },\n s: {\n description: [ServerDescription],\n options: [Object: null prototype],\n state: 'connected',\n operationCount: 0\n },\n monitor: Monitor {\n _events: [Object: null prototype],\n _eventsCount: 4,\n _maxListeners: undefined,\n component: 'topology',\n server: [Circular *1],\n connection: [Connection],\n cancellationToken: [CancellationToken],\n monitorId: [MonitorInterval],\n s: [Object],\n address: 'localhost:31000',\n options: [Object],\n isRunningInFaasEnv: false,\n mongoLogger: undefined,\n rttSampler: [RTTSampler],\n connectOptions: [Object],\n [Symbol(kCapture)]: false\n },\n [Symbol(kCapture)]: false\n }\n]"} +{"relevantHostAddresses":[{"host":"localhost","port":31000},{"host":"localhost","port":31000}]} +{"server":"[\n 'localhost:31001',\n Server {\n _events: [Object: null prototype] {\n serverHeartbeatStarted: [Function (anonymous)],\n serverHeartbeatSucceeded: [Function (anonymous)],\n serverHeartbeatFailed: [Function (anonymous)],\n commandStarted: [Function (anonymous)],\n commandSucceeded: [Function (anonymous)],\n commandFailed: [Function (anonymous)],\n connectionPoolCreated: [Function (anonymous)],\n connectionPoolReady: [Function (anonymous)],\n connectionPoolCleared: [Function (anonymous)],\n connectionPoolClosed: [Function (anonymous)],\n connectionCreated: [Function (anonymous)],\n connectionReady: [Function (anonymous)],\n connectionClosed: [Function (anonymous)],\n connectionCheckOutStarted: [Function (anonymous)],\n connectionCheckOutFailed: [Function (anonymous)],\n connectionCheckedOut: [Function (anonymous)],\n connectionCheckedIn: [Function (anonymous)],\n descriptionReceived: [Function (anonymous)]\n },\n _eventsCount: 18,\n _maxListeners: undefined,\n serverApi: undefined,\n topology: Topology {\n _events: [Object: null prototype],\n _eventsCount: 26,\n _maxListeners: undefined,\n client: [MongoClient],\n waitQueue: [List],\n s: [Object],\n mongoLogger: undefined,\n component: 'topology',\n connectionLock: undefined,\n [Symbol(kCapture)]: false\n },\n pool: ConnectionPool {\n _events: [Object: null prototype],\n _eventsCount: 15,\n _maxListeners: undefined,\n options: [Object],\n poolState: 'ready',\n server: [Circular *1],\n connections: [List],\n pending: 0,\n checkedOut: Set(0) {},\n minPoolSizeTimer: undefined,\n generation: 0,\n serviceGenerations: Map(0) {},\n connectionCounter: Object [Generator] {},\n cancellationToken: [CancellationToken],\n waitQueue: [List],\n metrics: [ConnectionPoolMetrics],\n processingWaitQueue: false,\n mongoLogger: undefined,\n component: 'connection',\n [Symbol(kCapture)]: false\n },\n s: {\n description: [ServerDescription],\n options: [Object: null prototype],\n state: 'connected',\n operationCount: 0\n },\n monitor: Monitor {\n _events: [Object: null prototype],\n _eventsCount: 4,\n _maxListeners: undefined,\n component: 'topology',\n server: [Circular *1],\n connection: [Connection],\n cancellationToken: [CancellationToken],\n monitorId: [MonitorInterval],\n s: [Object],\n address: 'localhost:31001',\n options: [Object],\n isRunningInFaasEnv: false,\n mongoLogger: undefined,\n rttSampler: [RTTSampler],\n connectOptions: [Object],\n [Symbol(kCapture)]: false\n },\n [Symbol(kCapture)]: false\n }\n]"} +{"relevantHostAddresses":[{"host":"localhost","port":31001}]} +{"server":"[\n 'localhost:31002',\n Server {\n _events: [Object: null prototype] {\n serverHeartbeatStarted: [Function (anonymous)],\n serverHeartbeatSucceeded: [Function (anonymous)],\n serverHeartbeatFailed: [Function (anonymous)],\n commandStarted: [Function (anonymous)],\n commandSucceeded: [Function (anonymous)],\n commandFailed: [Function (anonymous)],\n connectionPoolCreated: [Function (anonymous)],\n connectionPoolReady: [Function (anonymous)],\n connectionPoolCleared: [Function (anonymous)],\n connectionPoolClosed: [Function (anonymous)],\n connectionCreated: [Function (anonymous)],\n connectionReady: [Function (anonymous)],\n connectionClosed: [Function (anonymous)],\n connectionCheckOutStarted: [Function (anonymous)],\n connectionCheckOutFailed: [Function (anonymous)],\n connectionCheckedOut: [Function (anonymous)],\n connectionCheckedIn: [Function (anonymous)],\n descriptionReceived: [Function (anonymous)]\n },\n _eventsCount: 18,\n _maxListeners: undefined,\n serverApi: undefined,\n topology: Topology {\n _events: [Object: null prototype],\n _eventsCount: 26,\n _maxListeners: undefined,\n client: [MongoClient],\n waitQueue: [List],\n s: [Object],\n mongoLogger: undefined,\n component: 'topology',\n connectionLock: undefined,\n [Symbol(kCapture)]: false\n },\n pool: ConnectionPool {\n _events: [Object: null prototype],\n _eventsCount: 15,\n _maxListeners: undefined,\n options: [Object],\n poolState: 'ready',\n server: [Circular *1],\n connections: [List],\n pending: 0,\n checkedOut: Set(0) {},\n minPoolSizeTimer: undefined,\n generation: 0,\n serviceGenerations: Map(0) {},\n connectionCounter: Object [Generator] {},\n cancellationToken: [CancellationToken],\n waitQueue: [List],\n metrics: [ConnectionPoolMetrics],\n processingWaitQueue: false,\n mongoLogger: undefined,\n component: 'connection',\n [Symbol(kCapture)]: false\n },\n s: {\n description: [ServerDescription],\n options: [Object: null prototype],\n state: 'connected',\n operationCount: 0\n },\n monitor: Monitor {\n _events: [Object: null prototype],\n _eventsCount: 4,\n _maxListeners: undefined,\n component: 'topology',\n server: [Circular *1],\n connection: [Connection],\n cancellationToken: [CancellationToken],\n monitorId: [MonitorInterval],\n s: [Object],\n address: 'localhost:31002',\n options: [Object],\n isRunningInFaasEnv: false,\n mongoLogger: undefined,\n rttSampler: [RTTSampler],\n connectOptions: [Object],\n [Symbol(kCapture)]: false\n },\n [Symbol(kCapture)]: false\n }\n]"} +{"relevantHostAddresses":[{"host":"localhost","port":31002}]} +{"server":"[\n 'localhost:31003',\n Server {\n _events: [Object: null prototype] {\n serverHeartbeatStarted: [Function (anonymous)],\n serverHeartbeatSucceeded: [Function (anonymous)],\n serverHeartbeatFailed: [Function (anonymous)],\n commandStarted: [Function (anonymous)],\n commandSucceeded: [Function (anonymous)],\n commandFailed: [Function (anonymous)],\n connectionPoolCreated: [Function (anonymous)],\n connectionPoolReady: [Function (anonymous)],\n connectionPoolCleared: [Function (anonymous)],\n connectionPoolClosed: [Function (anonymous)],\n connectionCreated: [Function (anonymous)],\n connectionReady: [Function (anonymous)],\n connectionClosed: [Function (anonymous)],\n connectionCheckOutStarted: [Function (anonymous)],\n connectionCheckOutFailed: [Function (anonymous)],\n connectionCheckedOut: [Function (anonymous)],\n connectionCheckedIn: [Function (anonymous)],\n descriptionReceived: [Function (anonymous)]\n },\n _eventsCount: 18,\n _maxListeners: undefined,\n serverApi: undefined,\n topology: Topology {\n _events: [Object: null prototype],\n _eventsCount: 26,\n _maxListeners: undefined,\n client: [MongoClient],\n waitQueue: [List],\n s: [Object],\n mongoLogger: undefined,\n component: 'topology',\n connectionLock: undefined,\n [Symbol(kCapture)]: false\n },\n pool: ConnectionPool {\n _events: [Object: null prototype],\n _eventsCount: 15,\n _maxListeners: undefined,\n options: [Object],\n poolState: 'paused',\n server: [Circular *1],\n connections: [List],\n pending: 0,\n checkedOut: Set(0) {},\n minPoolSizeTimer: undefined,\n generation: 0,\n serviceGenerations: Map(0) {},\n connectionCounter: Object [Generator] {},\n cancellationToken: [CancellationToken],\n waitQueue: [List],\n metrics: [ConnectionPoolMetrics],\n processingWaitQueue: false,\n mongoLogger: undefined,\n component: 'connection',\n [Symbol(kCapture)]: false\n },\n s: {\n description: [ServerDescription],\n options: [Object: null prototype],\n state: 'connected',\n operationCount: 0\n },\n monitor: Monitor {\n _events: [Object: null prototype],\n _eventsCount: 4,\n _maxListeners: undefined,\n component: 'topology',\n server: [Circular *1],\n connection: [Connection],\n cancellationToken: [CancellationToken],\n monitorId: [MonitorInterval],\n s: [Object],\n address: 'localhost:31003',\n options: [Object],\n isRunningInFaasEnv: false,\n mongoLogger: undefined,\n rttSampler: [RTTSampler],\n connectOptions: [Object],\n [Symbol(kCapture)]: false\n },\n [Symbol(kCapture)]: false\n }\n]"} +{"relevantHostAddresses":[{"host":"localhost","port":31003}]} +{"beforeExitHappened":true} +{"server":"[\n 'localhost:31000',\n Server {\n _events: [Object: null prototype] {\n serverHeartbeatStarted: [Function (anonymous)],\n serverHeartbeatSucceeded: [Function (anonymous)],\n serverHeartbeatFailed: [Function (anonymous)],\n commandStarted: [Function (anonymous)],\n commandSucceeded: [Function (anonymous)],\n commandFailed: [Function (anonymous)],\n connectionPoolCreated: [Function (anonymous)],\n connectionPoolReady: [Function (anonymous)],\n connectionPoolCleared: [Function (anonymous)],\n connectionPoolClosed: [Function (anonymous)],\n connectionCreated: [Function (anonymous)],\n connectionReady: [Function (anonymous)],\n connectionClosed: [Function (anonymous)],\n connectionCheckOutStarted: [Function (anonymous)],\n connectionCheckOutFailed: [Function (anonymous)],\n connectionCheckedOut: [Function (anonymous)],\n connectionCheckedIn: [Function (anonymous)],\n descriptionReceived: [Function (anonymous)]\n },\n _eventsCount: 18,\n _maxListeners: undefined,\n serverApi: undefined,\n topology: Topology {\n _events: [Object: null prototype],\n _eventsCount: 26,\n _maxListeners: undefined,\n client: [MongoClient],\n waitQueue: [List],\n s: [Object],\n mongoLogger: undefined,\n component: 'topology',\n connectionLock: undefined,\n [Symbol(kCapture)]: false\n },\n pool: ConnectionPool {\n _events: [Object: null prototype],\n _eventsCount: 15,\n _maxListeners: undefined,\n options: [Object],\n poolState: 'ready',\n server: [Circular *1],\n connections: [List],\n pending: 0,\n checkedOut: Set(0) {},\n minPoolSizeTimer: undefined,\n generation: 0,\n serviceGenerations: Map(0) {},\n connectionCounter: Object [Generator] {},\n cancellationToken: [CancellationToken],\n waitQueue: [List],\n metrics: [ConnectionPoolMetrics],\n processingWaitQueue: false,\n mongoLogger: undefined,\n component: 'connection',\n [Symbol(kCapture)]: false\n },\n s: {\n description: [ServerDescription],\n options: [Object: null prototype],\n state: 'connected',\n operationCount: 0\n },\n monitor: Monitor {\n _events: [Object: null prototype],\n _eventsCount: 4,\n _maxListeners: undefined,\n component: 'topology',\n server: [Circular *1],\n connection: [Connection],\n cancellationToken: [CancellationToken],\n monitorId: [MonitorInterval],\n s: [Object],\n address: 'localhost:31000',\n options: [Object],\n isRunningInFaasEnv: false,\n mongoLogger: undefined,\n rttSampler: [RTTSampler],\n connectOptions: [Object],\n [Symbol(kCapture)]: false\n },\n [Symbol(kCapture)]: false\n }\n]"} +{"relevantHostAddresses":[{"host":"localhost","port":31000},{"host":"localhost","port":31000}]} +{"server":"[\n 'localhost:31001',\n Server {\n _events: [Object: null prototype] {\n serverHeartbeatStarted: [Function (anonymous)],\n serverHeartbeatSucceeded: [Function (anonymous)],\n serverHeartbeatFailed: [Function (anonymous)],\n commandStarted: [Function (anonymous)],\n commandSucceeded: [Function (anonymous)],\n commandFailed: [Function (anonymous)],\n connectionPoolCreated: [Function (anonymous)],\n connectionPoolReady: [Function (anonymous)],\n connectionPoolCleared: [Function (anonymous)],\n connectionPoolClosed: [Function (anonymous)],\n connectionCreated: [Function (anonymous)],\n connectionReady: [Function (anonymous)],\n connectionClosed: [Function (anonymous)],\n connectionCheckOutStarted: [Function (anonymous)],\n connectionCheckOutFailed: [Function (anonymous)],\n connectionCheckedOut: [Function (anonymous)],\n connectionCheckedIn: [Function (anonymous)],\n descriptionReceived: [Function (anonymous)]\n },\n _eventsCount: 18,\n _maxListeners: undefined,\n serverApi: undefined,\n topology: Topology {\n _events: [Object: null prototype],\n _eventsCount: 26,\n _maxListeners: undefined,\n client: [MongoClient],\n waitQueue: [List],\n s: [Object],\n mongoLogger: undefined,\n component: 'topology',\n connectionLock: undefined,\n [Symbol(kCapture)]: false\n },\n pool: ConnectionPool {\n _events: [Object: null prototype],\n _eventsCount: 15,\n _maxListeners: undefined,\n options: [Object],\n poolState: 'ready',\n server: [Circular *1],\n connections: [List],\n pending: 0,\n checkedOut: Set(0) {},\n minPoolSizeTimer: undefined,\n generation: 0,\n serviceGenerations: Map(0) {},\n connectionCounter: Object [Generator] {},\n cancellationToken: [CancellationToken],\n waitQueue: [List],\n metrics: [ConnectionPoolMetrics],\n processingWaitQueue: false,\n mongoLogger: undefined,\n component: 'connection',\n [Symbol(kCapture)]: false\n },\n s: {\n description: [ServerDescription],\n options: [Object: null prototype],\n state: 'connected',\n operationCount: 0\n },\n monitor: Monitor {\n _events: [Object: null prototype],\n _eventsCount: 4,\n _maxListeners: undefined,\n component: 'topology',\n server: [Circular *1],\n connection: [Connection],\n cancellationToken: [CancellationToken],\n monitorId: [MonitorInterval],\n s: [Object],\n address: 'localhost:31001',\n options: [Object],\n isRunningInFaasEnv: false,\n mongoLogger: undefined,\n rttSampler: [RTTSampler],\n connectOptions: [Object],\n [Symbol(kCapture)]: false\n },\n [Symbol(kCapture)]: false\n }\n]"} +{"relevantHostAddresses":[{"host":"localhost","port":31001}]} +{"server":"[\n 'localhost:31002',\n Server {\n _events: [Object: null prototype] {\n serverHeartbeatStarted: [Function (anonymous)],\n serverHeartbeatSucceeded: [Function (anonymous)],\n serverHeartbeatFailed: [Function (anonymous)],\n commandStarted: [Function (anonymous)],\n commandSucceeded: [Function (anonymous)],\n commandFailed: [Function (anonymous)],\n connectionPoolCreated: [Function (anonymous)],\n connectionPoolReady: [Function (anonymous)],\n connectionPoolCleared: [Function (anonymous)],\n connectionPoolClosed: [Function (anonymous)],\n connectionCreated: [Function (anonymous)],\n connectionReady: [Function (anonymous)],\n connectionClosed: [Function (anonymous)],\n connectionCheckOutStarted: [Function (anonymous)],\n connectionCheckOutFailed: [Function (anonymous)],\n connectionCheckedOut: [Function (anonymous)],\n connectionCheckedIn: [Function (anonymous)],\n descriptionReceived: [Function (anonymous)]\n },\n _eventsCount: 18,\n _maxListeners: undefined,\n serverApi: undefined,\n topology: Topology {\n _events: [Object: null prototype],\n _eventsCount: 26,\n _maxListeners: undefined,\n client: [MongoClient],\n waitQueue: [List],\n s: [Object],\n mongoLogger: undefined,\n component: 'topology',\n connectionLock: undefined,\n [Symbol(kCapture)]: false\n },\n pool: ConnectionPool {\n _events: [Object: null prototype],\n _eventsCount: 15,\n _maxListeners: undefined,\n options: [Object],\n poolState: 'ready',\n server: [Circular *1],\n connections: [List],\n pending: 0,\n checkedOut: Set(0) {},\n minPoolSizeTimer: undefined,\n generation: 0,\n serviceGenerations: Map(0) {},\n connectionCounter: Object [Generator] {},\n cancellationToken: [CancellationToken],\n waitQueue: [List],\n metrics: [ConnectionPoolMetrics],\n processingWaitQueue: false,\n mongoLogger: undefined,\n component: 'connection',\n [Symbol(kCapture)]: false\n },\n s: {\n description: [ServerDescription],\n options: [Object: null prototype],\n state: 'connected',\n operationCount: 0\n },\n monitor: Monitor {\n _events: [Object: null prototype],\n _eventsCount: 4,\n _maxListeners: undefined,\n component: 'topology',\n server: [Circular *1],\n connection: [Connection],\n cancellationToken: [CancellationToken],\n monitorId: [MonitorInterval],\n s: [Object],\n address: 'localhost:31002',\n options: [Object],\n isRunningInFaasEnv: false,\n mongoLogger: undefined,\n rttSampler: [RTTSampler],\n connectOptions: [Object],\n [Symbol(kCapture)]: false\n },\n [Symbol(kCapture)]: false\n }\n]"} +{"relevantHostAddresses":[{"host":"localhost","port":31002}]} +{"server":"[\n 'localhost:31003',\n Server {\n _events: [Object: null prototype] {\n serverHeartbeatStarted: [Function (anonymous)],\n serverHeartbeatSucceeded: [Function (anonymous)],\n serverHeartbeatFailed: [Function (anonymous)],\n commandStarted: [Function (anonymous)],\n commandSucceeded: [Function (anonymous)],\n commandFailed: [Function (anonymous)],\n connectionPoolCreated: [Function (anonymous)],\n connectionPoolReady: [Function (anonymous)],\n connectionPoolCleared: [Function (anonymous)],\n connectionPoolClosed: [Function (anonymous)],\n connectionCreated: [Function (anonymous)],\n connectionReady: [Function (anonymous)],\n connectionClosed: [Function (anonymous)],\n connectionCheckOutStarted: [Function (anonymous)],\n connectionCheckOutFailed: [Function (anonymous)],\n connectionCheckedOut: [Function (anonymous)],\n connectionCheckedIn: [Function (anonymous)],\n descriptionReceived: [Function (anonymous)]\n },\n _eventsCount: 18,\n _maxListeners: undefined,\n serverApi: undefined,\n topology: Topology {\n _events: [Object: null prototype],\n _eventsCount: 26,\n _maxListeners: undefined,\n client: [MongoClient],\n waitQueue: [List],\n s: [Object],\n mongoLogger: undefined,\n component: 'topology',\n connectionLock: undefined,\n [Symbol(kCapture)]: false\n },\n pool: ConnectionPool {\n _events: [Object: null prototype],\n _eventsCount: 15,\n _maxListeners: undefined,\n options: [Object],\n poolState: 'paused',\n server: [Circular *1],\n connections: [List],\n pending: 0,\n checkedOut: Set(0) {},\n minPoolSizeTimer: undefined,\n generation: 0,\n serviceGenerations: Map(0) {},\n connectionCounter: Object [Generator] {},\n cancellationToken: [CancellationToken],\n waitQueue: [List],\n metrics: [ConnectionPoolMetrics],\n processingWaitQueue: false,\n mongoLogger: undefined,\n component: 'connection',\n [Symbol(kCapture)]: false\n },\n s: {\n description: [ServerDescription],\n options: [Object: null prototype],\n state: 'connected',\n operationCount: 0\n },\n monitor: Monitor {\n _events: [Object: null prototype],\n _eventsCount: 4,\n _maxListeners: undefined,\n component: 'topology',\n server: [Circular *1],\n connection: [Connection],\n cancellationToken: [CancellationToken],\n monitorId: [MonitorInterval],\n s: [Object],\n address: 'localhost:31003',\n options: [Object],\n isRunningInFaasEnv: false,\n mongoLogger: undefined,\n rttSampler: [RTTSampler],\n connectOptions: [Object],\n [Symbol(kCapture)]: false\n },\n [Symbol(kCapture)]: false\n }\n]"} +{"relevantHostAddresses":[{"host":"localhost","port":31003}]} +{"beforeExitHappened":true} diff --git a/test/integration/node-specific/client_close.test.ts b/test/integration/node-specific/client_close.test.ts index 3289e5c807..f67043c9cb 100644 --- a/test/integration/node-specific/client_close.test.ts +++ b/test/integration/node-specific/client_close.test.ts @@ -1,4 +1,6 @@ /* eslint-disable @typescript-eslint/no-empty-function */ +import { expect } from 'chai'; +import { MongoClient } from '../../mongodb'; import { type TestConfiguration } from '../../tools/runner/config'; import { runScriptAndGetProcessInfo } from './resource_tracking_script_builder'; @@ -103,43 +105,46 @@ describe('MongoClient.close() Integration', () => { describe('Connection Monitoring', () => { describe('Node.js resource: Socket', () => { it.only('no sockets remain after client.close()', metadata, async function () { - await runScriptAndGetProcessInfo( + const run = async function({ MongoClient, uri, log, expect }) { + const client = new MongoClient(uri); + await client.connect(); + + // returns all active tcp endpoints + const connectionMonitoringReport = () => + process.report + .getReport() + .libuv.filter(r => r.type === 'tcp' && r.is_active) + .map(r => r.remoteEndpoint); + + // assert socket creation + // there should be two sockets for each server: + // client connection socket + // monitor socket + log(connectionMonitoringReport()); + const servers = client.topology?.s.servers; + for (const server of servers) { + const { host, port } = server[1].s.description.hostAddress; + log('MONITOR OF ', host, port, ':\n', server[1].monitor.address); + const relevantHostAddresses = connectionMonitoringReport().filter(r => r.host === host && r.port === port); + //log({ relevantHostAddresses }); + // expect(relevantHostAddresses).length.to.be.gte(2); + } + + await client.close(); + + // assert socket destruction + for (const server of servers) { + const { host, port } = server[1].s.description.hostAddress; + expect(connectionMonitoringReport()).to.not.deep.include({ host, port }); + } + }; + /* await runScriptAndGetProcessInfo( 'socket-connection-monitoring', config, - async function run({ MongoClient, uri, log, expect }) { - const client = new MongoClient(uri); - await client.connect(); - - // returns all active tcp endpoints - const connectionMonitoringReport = () => - process.report - .getReport() - .libuv.filter(r => r.type === 'tcp' && r.is_active) - .map(r => r.remoteEndpoint); + run + ); */ - log({ monreport: connectionMonitoringReport() }); - // assert socket creation - // there should be two sockets for each server: - // client connection socket - // monitor socket - /* const servers = client.topology?.s.servers; - for (const server of servers) { - log({ monreport: connectionMonitoringReport() }); - const { host, port } = server[1].s.description.hostAddress; - const relevantHostAddresses = connectionMonitoringReport().filter(r => r.host === host && r.port === port); - log({ relevantHostAddresses }); - expect(relevantHostAddresses).length.to.be.gte(2); - } */ - - await client.close(); - - // assert socket destruction - for (const server of servers) { - const { host, port } = server[1].s.description.hostAddress; - expect(connectionMonitoringReport()).to.not.deep.include({ host, port }); - } - } - ); + await run({ MongoClient, uri: config.uri, log: console.log, expect }); }); }); });