Skip to content

Commit c93c139

Browse files
remove dependency on heapsnapshot
1 parent 66c18b7 commit c93c139

3 files changed

Lines changed: 18 additions & 22 deletions

File tree

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

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const MB_PERMITTED_OFFSET = 5;
1717
describe('Driver Resources', () => {
1818
let startingMemoryUsed;
1919
let endingMemoryUsed;
20-
let heap;
20+
let clientsInMemory;
2121

2222
beforeEach(function () {
2323
if (globalThis.AbortController == null) {
@@ -34,12 +34,6 @@ describe('Driver Resources', () => {
3434

3535
context('on MongoClient.close()', () => {
3636
before('create leak reproduction script', async function () {
37-
if (process.version.includes('v24')) {
38-
if (this.test) {
39-
this.test.skipReason = 'TODO(NODE-6945): Fix v24 heap snapshot parsing';
40-
}
41-
this.test?.skip();
42-
}
4337
if (globalThis.AbortController == null || typeof this.configuration.serverApi === 'string') {
4438
return;
4539
}
@@ -58,7 +52,7 @@ describe('Driver Resources', () => {
5852

5953
startingMemoryUsed = res.startingMemoryUsed;
6054
endingMemoryUsed = res.endingMemoryUsed;
61-
heap = res.heap;
55+
clientsInMemory = res.clientsInMemory;
6256
});
6357

6458
describe('ending memory usage', () => {
@@ -77,11 +71,10 @@ describe('Driver Resources', () => {
7771

7872
describe('ending heap snapshot', () => {
7973
it('has 0 MongoClients in memory', async () => {
80-
const clients = heap.nodes.filter(n => n.name === 'MongoClient' && n.type === 'object');
8174
// lengthOf crashes chai b/c it tries to print out a gigantic diff
8275
expect(
83-
clients.length,
84-
`expected no MongoClients in the heapsnapshot, found ${clients.length}`
76+
clientsInMemory,
77+
`expected no MongoClients in the heapsnapshot, found ${clientsInMemory}`
8578
).to.equal(0);
8679
});
8780
});

test/integration/node-specific/resource_tracking_script_builder.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ export async function runScriptAndReturnHeapInfo(
106106
};
107107
log('starting');
108108
const scriptName = `${name}.cjs`;
109-
const heapsnapshotFile = `${name}.heapsnapshot.json`;
110109

111110
const scriptContent = await testScriptFactory(
112111
name,
@@ -148,28 +147,27 @@ export async function runScriptAndReturnHeapInfo(
148147
const startingMemoryUsed = starting.value[0].startingMemoryUsed;
149148
const endingMemoryUsed = ending.value[0].endingMemoryUsed;
150149

150+
const {
151+
value: [{ clientsInMemory }]
152+
} = await messages.next();
153+
151154
// make sure the process ended
152155
const [exitCode] = await willClose;
153156

154157
log('child process closed.');
155158

156159
expect(exitCode, 'process should have exited with zero').to.equal(0);
157160

158-
const heap = await readFile(heapsnapshotFile, { encoding: 'utf8' }).then(c =>
159-
parseSnapshot(JSON.parse(c))
160-
);
161-
162161
log('done.');
163162

164163
// If any of the above throws we won't reach these unlinks that clean up the created files.
165164
// This is intentional so that when debugging the file will still be present to check it for errors
166165
await unlink(scriptName);
167-
await unlink(heapsnapshotFile);
168166

169167
return {
170168
startingMemoryUsed,
171169
endingMemoryUsed,
172-
heap
170+
clientsInMemory
173171
};
174172
}
175173

test/tools/fixtures/heap_resource_script.in.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,16 @@ async function main() {
5959
process.send({ endingMemoryUsed });
6060
log('second message sent.');
6161

62-
const start = now();
63-
v8.writeHeapSnapshot(`${name}.heapsnapshot.json`);
64-
const end = now();
62+
const clientsInMemory = v8.queryObjects(MongoClient);
6563

66-
log(`heap snapshot written in ${end - start}ms. script exiting`);
64+
process.send({ clientsInMemory });
65+
66+
log('clients instances in memory sent.');
67+
// const start = now();
68+
// v8.writeHeapSnapshot(`${name}.heapsnapshot.json`);
69+
// const end = now();
70+
71+
// log(`heap snapshot written in ${end - start}ms. script exiting`);
6772
}
6873

6974
main()

0 commit comments

Comments
 (0)