• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3// Flags: --expose-gc --harmony-weak-refs
4
5const common = require('../common');
6const assert = require('assert');
7
8const g = new globalThis.FinalizationGroup(common.mustCallAtLeast(() => {
9  throw new Error('test');
10}, 1));
11g.register({}, 42);
12
13setTimeout(() => {
14  globalThis.gc();
15  assert.throws(() => {
16    g.cleanupSome();
17  }, {
18    name: 'Error',
19    message: 'test',
20  });
21
22  // Give the callbacks scheduled by global.gc() time to run, as the underlying
23  // uv_async_t is unref’ed.
24  setTimeout(() => {}, 200);
25}, 200);
26
27process.on('uncaughtException', common.mustCall());
28