@@ -7,7 +7,6 @@ import { inspect } from 'node:util';
77
88import { AssertionError , expect } from 'chai' ;
99import type * as timers from 'timers' ;
10- import { parseSnapshot } from 'v8-heapsnapshot' ;
1110
1211import type * as mongodb from '../../../src' ;
1312import { type TestConfiguration } from '../../tools/runner/config' ;
@@ -105,7 +104,6 @@ export async function runScriptAndReturnHeapInfo(
105104 } ;
106105 log ( 'starting' ) ;
107106 const scriptName = `${ name } .cjs` ;
108- const heapsnapshotFile = `${ name } .heapsnapshot.json` ;
109107
110108 const scriptContent = await testScriptFactory (
111109 name ,
@@ -144,8 +142,16 @@ export async function runScriptAndReturnHeapInfo(
144142
145143 log ( 'fetching messages 3: ' , ending ) ;
146144
147- const startingMemoryUsed = starting . value [ 0 ] . startingMemoryUsed ;
148- const endingMemoryUsed = ending . value [ 0 ] . endingMemoryUsed ;
145+ const {
146+ value : [ { startingMemoryUsed } ]
147+ } = starting ;
148+ const {
149+ value : [ { endingMemoryUsed } ]
150+ } = ending ;
151+
152+ const {
153+ value : [ { clientsInMemory } ]
154+ } = await messages . next ( ) ;
149155
150156 // make sure the process ended
151157 const [ exitCode ] = await willClose ;
@@ -154,21 +160,16 @@ export async function runScriptAndReturnHeapInfo(
154160
155161 expect ( exitCode , 'process should have exited with zero' ) . to . equal ( 0 ) ;
156162
157- const heap = await readFile ( heapsnapshotFile , { encoding : 'utf8' } ) . then ( c =>
158- parseSnapshot ( JSON . parse ( c ) )
159- ) ;
160-
161163 log ( 'done.' ) ;
162164
163165 // If any of the above throws we won't reach these unlinks that clean up the created files.
164166 // This is intentional so that when debugging the file will still be present to check it for errors
165167 await unlink ( scriptName ) ;
166- await unlink ( heapsnapshotFile ) ;
167168
168169 return {
169170 startingMemoryUsed,
170171 endingMemoryUsed,
171- heap
172+ clientsInMemory
172173 } ;
173174}
174175
0 commit comments