mirror of
https://github.com/nodejs/node.git
synced 2025-04-28 13:40:37 +00:00

PR-URL: https://github.com/nodejs/node/pull/56712 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
24 lines
746 B
JavaScript
24 lines
746 B
JavaScript
// Flags: --expose-gc
|
|
'use strict';
|
|
const common = require('../common');
|
|
|
|
// This test verifies that when a V8 FinalizationRegistryCleanupTask is queue
|
|
// at the last moment when JavaScript can be executed, the callback of a
|
|
// FinalizationRegistry will not be invoked and the process should exit
|
|
// normally.
|
|
|
|
const reg = new FinalizationRegistry(
|
|
common.mustNotCall('This FinalizationRegistry callback should never be called'));
|
|
|
|
function register() {
|
|
// Create a temporary object in a new function scope to allow it to be GC-ed.
|
|
reg.register({});
|
|
}
|
|
|
|
process.on('exit', () => {
|
|
// This is the final chance to execute JavaScript.
|
|
register();
|
|
// Queue a FinalizationRegistryCleanupTask by a testing gc request.
|
|
globalThis.gc();
|
|
});
|