mirror of
https://github.com/nodejs/node.git
synced 2026-12-06 18:38:44 -05:00
PR-URL: https://github.com/nodejs/node/pull/32831 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Jiawen Geng <technicalcute@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
28 lines
602 B
JavaScript
28 lines
602 B
JavaScript
'use strict';
|
||
|
||
// Flags: --expose-gc --harmony-weak-refs
|
||
|
||
const common = require('../common');
|
||
const assert = require('assert');
|
||
|
||
const g = new globalThis.FinalizationRegistry(common.mustCallAtLeast(() => {
|
||
throw new Error('test');
|
||
}, 1));
|
||
g.register({}, 42);
|
||
|
||
setTimeout(() => {
|
||
globalThis.gc();
|
||
assert.throws(() => {
|
||
g.cleanupSome();
|
||
}, {
|
||
name: 'Error',
|
||
message: 'test',
|
||
});
|
||
|
||
// Give the callbacks scheduled by global.gc() time to run, as the underlying
|
||
// uv_async_t is unref’ed.
|
||
setTimeout(() => {}, 200);
|
||
}, 200);
|
||
|
||
process.on('uncaughtException', common.mustCall());
|