Skip to content

Commit 540ec7e

Browse files
author
Gabriel Schulhof
committed
fixup! testFinalizerException to gc until it throws
1 parent f04eaa7 commit 540ec7e

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

test/js-native-api/test_exception/testFinalizerException.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,24 @@ if (process.argv[2] === 'child') {
99
} catch (anException) {
1010
anException.binding.createExternal();
1111
}
12-
const interval = setInterval(() => {
13-
clearInterval(interval);
14-
}, 100);
12+
13+
// Collect garbage 10 times. At least one of those should throw the exception
14+
// and cause the whole process to bail with it, its text printed to stderr and
15+
// asserted by the parent process to match expectations.
16+
let gcCount = 10;
17+
(function gcLoop() {
18+
global.gc();
19+
if (--gcCount > 0) {
20+
setImmediate(() => gcLoop());
21+
}
22+
})();
1523
return;
1624
}
1725

1826
const assert = require('assert');
1927
const { spawnSync } = require('child_process');
20-
const child = spawnSync(process.execPath, [ __filename, 'child' ]);
28+
const child = spawnSync(process.execPath, [
29+
'--expose-gc', __filename, 'child'
30+
]);
2131
assert.strictEqual(child.signal, null);
2232
assert.match(child.stderr.toString(), /Error during Finalize/m);

0 commit comments

Comments
 (0)