From 0b86f2ec9eb7163af31dcb9910f52f21dba2f2b6 Mon Sep 17 00:00:00 2001 From: tannal Date: Tue, 13 Aug 2024 18:28:21 +0800 Subject: [PATCH] test: merge ongc and gcutil into gc.js PR-URL: https://github.com/nodejs/node/pull/54355 Reviewed-By: Joyee Cheung Reviewed-By: Chengzhong Wu --- test/addons/cppgc-object/test.js | 6 +- .../test-async-local-storage-gcable.js | 2 +- test/common/README.md | 2 +- test/common/gc.js | 69 ++++++++++++++++++- test/common/index.js | 25 ------- test/common/ongc.js | 32 --------- .../6_object_wrap/test-object-wrap-ref.js | 3 +- test/js-native-api/7_factory_wrap/test.js | 5 +- test/js-native-api/8_passing_wrapped/test.js | 5 +- test/js-native-api/test_finalizer/test.js | 10 +-- test/js-native-api/test_general/test.js | 7 +- .../test_general/testFinalizer.js | 5 +- test/js-native-api/test_reference/test.js | 3 +- .../test.js | 3 +- test/parallel/test-common-gc.js | 2 +- .../parallel/test-domain-async-id-map-leak.js | 5 +- .../test-gc-http-client-connaborted.js | 2 +- test/parallel/test-gc-net-timeout.js | 2 +- test/parallel/test-gc-tls-external-memory.js | 2 +- ...t-http-server-connections-checking-leak.js | 2 +- .../test-http-server-keepalive-req-gc.js | 2 +- ...-https-server-connections-checking-leak.js | 2 +- .../test-internal-util-weakreference.js | 5 +- test/parallel/test-net-connect-memleak.js | 2 +- test/parallel/test-primitive-timer-leak.js | 2 +- test/parallel/test-tls-connect-memleak.js | 2 +- test/parallel/test-v8-serialize-leak.js | 3 +- .../test-zlib-invalid-input-memory.js | 2 +- .../sequential/test-gc-http-client-onerror.js | 2 +- .../sequential/test-gc-http-client-timeout.js | 2 +- test/sequential/test-gc-http-client.js | 2 +- 31 files changed, 119 insertions(+), 99 deletions(-) delete mode 100644 test/common/ongc.js diff --git a/test/addons/cppgc-object/test.js b/test/addons/cppgc-object/test.js index 6d45becba2700f..e18b6e17b88df9 100644 --- a/test/addons/cppgc-object/test.js +++ b/test/addons/cppgc-object/test.js @@ -3,7 +3,7 @@ // Flags: --expose-gc const common = require('../../common'); - +const { gcUntil } = require('../../common/gc'); // Verify that addons can create GarbageCollected objects and // have them traced properly. @@ -35,7 +35,7 @@ setTimeout(async function() { for (let i = 0; i < count; ++i) { array[i] = new CppGCed(); } - await common.gcUntil( + await gcUntil( 'All old CppGCed are destroyed', () => states[kDestructCount] === count, ); @@ -44,7 +44,7 @@ setTimeout(async function() { array = null; globalThis.gc(); - await common.gcUntil( + await gcUntil( 'All old CppGCed are destroyed', () => states[kDestructCount] === count * 2, ); diff --git a/test/async-hooks/test-async-local-storage-gcable.js b/test/async-hooks/test-async-local-storage-gcable.js index f0d23a0d22793b..ef3f15677463f8 100644 --- a/test/async-hooks/test-async-local-storage-gcable.js +++ b/test/async-hooks/test-async-local-storage-gcable.js @@ -6,7 +6,7 @@ const common = require('../common'); const { AsyncLocalStorage } = require('async_hooks'); -const onGC = require('../common/ongc'); +const { onGC } = require('../common/gc'); let asyncLocalStorage = new AsyncLocalStorage(); diff --git a/test/common/README.md b/test/common/README.md index d9e0323dccf1eb..2b7021a142fc58 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -982,7 +982,7 @@ module exports a single `onGC()` function. ```js require('../common'); -const onGC = require('../common/ongc'); +const { onGC } = require('../common/gc'); onGC({}, { ongc() { console.log('collected'); } }); ``` diff --git a/test/common/gc.js b/test/common/gc.js index 8e2c5ee5da4630..82cc4c79edc3dd 100644 --- a/test/common/gc.js +++ b/test/common/gc.js @@ -1,9 +1,72 @@ 'use strict'; const wait = require('timers/promises').setTimeout; +const assert = require('assert'); +const common = require('../common'); +const gcTrackerMap = new WeakMap(); +const gcTrackerTag = 'NODE_TEST_COMMON_GC_TRACKER'; -// TODO(joyeecheung): merge ongc.js and gcUntil from common/index.js -// into this. +/** + * Installs a garbage collection listener for the specified object. + * Uses async_hooks for GC tracking, which may affect test functionality. + * A full setImmediate() invocation passes between a global.gc() call and the listener being invoked. + * @param {object} obj - The target object to track for garbage collection. + * @param {object} gcListener - The listener object containing the ongc callback. + * @param {Function} gcListener.ongc - The function to call when the target object is garbage collected. + */ +function onGC(obj, gcListener) { + const async_hooks = require('async_hooks'); + + const onGcAsyncHook = async_hooks.createHook({ + init: common.mustCallAtLeast(function(id, type) { + if (this.trackedId === undefined) { + assert.strictEqual(type, gcTrackerTag); + this.trackedId = id; + } + }), + destroy(id) { + assert.notStrictEqual(this.trackedId, -1); + if (id === this.trackedId) { + this.gcListener.ongc(); + onGcAsyncHook.disable(); + } + }, + }).enable(); + onGcAsyncHook.gcListener = gcListener; + + gcTrackerMap.set(obj, new async_hooks.AsyncResource(gcTrackerTag)); + obj = null; +} + +/** + * Repeatedly triggers garbage collection until a specified condition is met or a maximum number of attempts is reached. + * @param {string|Function} [name] - Optional name, used in the rejection message if the condition is not met. + * @param {Function} condition - A function that returns true when the desired condition is met. + * @returns {Promise} A promise that resolves when the condition is met, or rejects after 10 failed attempts. + */ +function gcUntil(name, condition) { + if (typeof name === 'function') { + condition = name; + name = undefined; + } + return new Promise((resolve, reject) => { + let count = 0; + function gcAndCheck() { + setImmediate(() => { + count++; + global.gc(); + if (condition()) { + resolve(); + } else if (count < 10) { + gcAndCheck(); + } else { + reject(name === undefined ? undefined : 'Test ' + name + ' failed'); + } + }); + } + gcAndCheck(); + }); +} // This function can be used to check if an object factor leaks or not, // but it needs to be used with care: @@ -124,4 +187,6 @@ module.exports = { checkIfCollectable, runAndBreathe, checkIfCollectableByCounting, + onGC, + gcUntil, }; diff --git a/test/common/index.js b/test/common/index.js index d93ef9cfffbb31..c36643203746cd 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -837,30 +837,6 @@ function skipIfDumbTerminal() { } } -function gcUntil(name, condition) { - if (typeof name === 'function') { - condition = name; - name = undefined; - } - return new Promise((resolve, reject) => { - let count = 0; - function gcAndCheck() { - setImmediate(() => { - count++; - global.gc(); - if (condition()) { - resolve(); - } else if (count < 10) { - gcAndCheck(); - } else { - reject(name === undefined ? undefined : 'Test ' + name + ' failed'); - } - }); - } - gcAndCheck(); - }); -} - function requireNoPackageJSONAbove(dir = __dirname) { let possiblePackage = path.join(dir, '..', 'package.json'); let lastPackage = null; @@ -966,7 +942,6 @@ const common = { expectsError, expectRequiredModule, expectWarning, - gcUntil, getArrayBufferViews, getBufferSources, getCallSite, diff --git a/test/common/ongc.js b/test/common/ongc.js deleted file mode 100644 index d361c55b51fe30..00000000000000 --- a/test/common/ongc.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; - -const common = require('../common'); -const assert = require('assert'); -const gcTrackerMap = new WeakMap(); -const gcTrackerTag = 'NODE_TEST_COMMON_GC_TRACKER'; - -function onGC(obj, gcListener) { - const async_hooks = require('async_hooks'); - - const onGcAsyncHook = async_hooks.createHook({ - init: common.mustCallAtLeast(function(id, type) { - if (this.trackedId === undefined) { - assert.strictEqual(type, gcTrackerTag); - this.trackedId = id; - } - }), - destroy(id) { - assert.notStrictEqual(this.trackedId, -1); - if (id === this.trackedId) { - this.gcListener.ongc(); - onGcAsyncHook.disable(); - } - }, - }).enable(); - onGcAsyncHook.gcListener = gcListener; - - gcTrackerMap.set(obj, new async_hooks.AsyncResource(gcTrackerTag)); - obj = null; -} - -module.exports = onGC; diff --git a/test/js-native-api/6_object_wrap/test-object-wrap-ref.js b/test/js-native-api/6_object_wrap/test-object-wrap-ref.js index 81832c195c1890..a7d866a6869515 100644 --- a/test/js-native-api/6_object_wrap/test-object-wrap-ref.js +++ b/test/js-native-api/6_object_wrap/test-object-wrap-ref.js @@ -3,11 +3,12 @@ 'use strict'; const common = require('../../common'); const addon = require(`./build/${common.buildType}/6_object_wrap`); +const { gcUntil } = require('../../common/gc'); (function scope() { addon.objectWrapDanglingReference({}); })(); -common.gcUntil('object-wrap-ref', () => { +gcUntil('object-wrap-ref', () => { return addon.objectWrapDanglingReferenceTest(); }); diff --git a/test/js-native-api/7_factory_wrap/test.js b/test/js-native-api/7_factory_wrap/test.js index fd9771d43bbed0..f2afc94807c569 100644 --- a/test/js-native-api/7_factory_wrap/test.js +++ b/test/js-native-api/7_factory_wrap/test.js @@ -4,6 +4,7 @@ const common = require('../../common'); const assert = require('assert'); const test = require(`./build/${common.buildType}/7_factory_wrap`); +const { gcUntil } = require('../../common/gc'); assert.strictEqual(test.finalizeCount, 0); async function runGCTests() { @@ -13,7 +14,7 @@ async function runGCTests() { assert.strictEqual(obj.plusOne(), 12); assert.strictEqual(obj.plusOne(), 13); })(); - await common.gcUntil('test 1', () => (test.finalizeCount === 1)); + await gcUntil('test 1', () => (test.finalizeCount === 1)); (() => { const obj2 = test.createObject(20); @@ -21,6 +22,6 @@ async function runGCTests() { assert.strictEqual(obj2.plusOne(), 22); assert.strictEqual(obj2.plusOne(), 23); })(); - await common.gcUntil('test 2', () => (test.finalizeCount === 2)); + await gcUntil('test 2', () => (test.finalizeCount === 2)); } runGCTests(); diff --git a/test/js-native-api/8_passing_wrapped/test.js b/test/js-native-api/8_passing_wrapped/test.js index d6da19fecd4de8..a192f6a7588f37 100644 --- a/test/js-native-api/8_passing_wrapped/test.js +++ b/test/js-native-api/8_passing_wrapped/test.js @@ -4,6 +4,7 @@ const common = require('../../common'); const assert = require('assert'); const addon = require(`./build/${common.buildType}/8_passing_wrapped`); +const { gcUntil } = require('../../common/gc'); async function runTest() { let obj1 = addon.createObject(10); @@ -14,7 +15,7 @@ async function runTest() { // Make sure the native destructor gets called. obj1 = null; obj2 = null; - await common.gcUntil('8_passing_wrapped', - () => (addon.finalizeCount() === 2)); + await gcUntil('8_passing_wrapped', + () => (addon.finalizeCount() === 2)); } runTest(); diff --git a/test/js-native-api/test_finalizer/test.js b/test/js-native-api/test_finalizer/test.js index cfbf57239c3a6d..502db40122e3a8 100644 --- a/test/js-native-api/test_finalizer/test.js +++ b/test/js-native-api/test_finalizer/test.js @@ -5,8 +5,10 @@ const common = require('../../common'); const test_finalizer = require(`./build/${common.buildType}/test_finalizer`); const assert = require('assert'); +const { gcUntil } = require('../../common/gc'); + // The goal of this test is to show that we can run "pure" finalizers in the -// current JS loop tick. Thus, we do not use common.gcUntil function works +// current JS loop tick. Thus, we do not use gcUntil function works // asynchronously using micro tasks. // We use IIFE for the obj scope instead of {} to be compatible with // non-V8 JS engines that do not support scoped variables. @@ -25,7 +27,7 @@ for (let i = 0; i < 10; ++i) { assert.strictEqual(test_finalizer.getFinalizerCallCount(), 1); // The finalizer that access JS cannot run synchronously. They are run in the -// next JS loop tick. Thus, we must use common.gcUntil. +// next JS loop tick. Thus, we must use gcUntil. async function runAsyncTests() { // We do not use common.mustCall() because we want to see the finalizer // called in response to GC and not as a part of env destruction. @@ -36,8 +38,8 @@ async function runAsyncTests() { const obj = {}; test_finalizer.addFinalizerWithJS(obj, () => { js_is_called = true; }); })(); - await common.gcUntil('ensure JS finalizer called', - () => (test_finalizer.getFinalizerCallCount() === 2)); + await gcUntil('ensure JS finalizer called', + () => (test_finalizer.getFinalizerCallCount() === 2)); assert(js_is_called); } runAsyncTests(); diff --git a/test/js-native-api/test_general/test.js b/test/js-native-api/test_general/test.js index 9072e734468964..3d4f2f9715678e 100644 --- a/test/js-native-api/test_general/test.js +++ b/test/js-native-api/test_general/test.js @@ -4,6 +4,7 @@ const common = require('../../common'); const test_general = require(`./build/${common.buildType}/test_general`); const assert = require('assert'); +const { gcUntil } = require('../../common/gc'); const val1 = '1'; const val2 = 1; @@ -79,9 +80,9 @@ async function runGCTests() { assert.strictEqual(test_general.derefItemWasCalled(), false); (() => test_general.wrap({}))(); - await common.gcUntil('deref_item() was called upon garbage collecting a ' + + await gcUntil('deref_item() was called upon garbage collecting a ' + 'wrapped object.', - () => test_general.derefItemWasCalled()); + () => test_general.derefItemWasCalled()); // Ensure that removing a wrap and garbage collecting does not fire the // finalize callback. @@ -89,7 +90,7 @@ async function runGCTests() { test_general.testFinalizeWrap(z); test_general.removeWrap(z); z = null; - await common.gcUntil( + await gcUntil( 'finalize callback was not called upon garbage collection.', () => (!test_general.finalizeWasCalled())); } diff --git a/test/js-native-api/test_general/testFinalizer.js b/test/js-native-api/test_general/testFinalizer.js index 54265d61bc37ff..975170249262a9 100644 --- a/test/js-native-api/test_general/testFinalizer.js +++ b/test/js-native-api/test_general/testFinalizer.js @@ -4,6 +4,7 @@ const common = require('../../common'); const test_general = require(`./build/${common.buildType}/test_general`); const assert = require('assert'); +const { gcUntil } = require('../../common/gc'); let finalized = {}; const callback = common.mustCall(2); @@ -30,7 +31,7 @@ async function testFinalizeAndWrap() { test_general.wrap(finalizeAndWrap); test_general.addFinalizerOnly(finalizeAndWrap, common.mustCall()); finalizeAndWrap = null; - await common.gcUntil('test finalize and wrap', - () => test_general.derefItemWasCalled()); + await gcUntil('test finalize and wrap', + () => test_general.derefItemWasCalled()); } testFinalizeAndWrap(); diff --git a/test/js-native-api/test_reference/test.js b/test/js-native-api/test_reference/test.js index e65847fbdb0596..34a1ac70ede24a 100644 --- a/test/js-native-api/test_reference/test.js +++ b/test/js-native-api/test_reference/test.js @@ -1,7 +1,8 @@ 'use strict'; // Flags: --expose-gc -const { gcUntil, buildType } = require('../../common'); +const { buildType } = require('../../common'); +const { gcUntil } = require('../../common/gc'); const assert = require('assert'); const test_reference = require(`./build/${buildType}/test_reference`); diff --git a/test/node-api/test_reference_by_node_api_version/test.js b/test/node-api/test_reference_by_node_api_version/test.js index 32530f681508c8..6a9078600e16d8 100644 --- a/test/node-api/test_reference_by_node_api_version/test.js +++ b/test/node-api/test_reference_by_node_api_version/test.js @@ -7,7 +7,8 @@ // and symbol types, while in newer versions they can be created for // any value type. // -const { gcUntil, buildType } = require('../../common'); +const { buildType } = require('../../common'); +const { gcUntil } = require('../../common/gc'); const assert = require('assert'); const addon_v8 = require(`./build/${buildType}/test_reference_obj_only`); const addon_new = require(`./build/${buildType}/test_reference_all_types`); diff --git a/test/parallel/test-common-gc.js b/test/parallel/test-common-gc.js index 96dc7e2e7b601d..f7d73ccd0423e3 100644 --- a/test/parallel/test-common-gc.js +++ b/test/parallel/test-common-gc.js @@ -1,7 +1,7 @@ 'use strict'; // Flags: --expose-gc const common = require('../common'); -const onGC = require('../common/ongc'); +const { onGC } = require('../common/gc'); { onGC({}, { ongc: common.mustCall() }); diff --git a/test/parallel/test-domain-async-id-map-leak.js b/test/parallel/test-domain-async-id-map-leak.js index 12e93ef3594eaa..c3215cd7ce9698 100644 --- a/test/parallel/test-domain-async-id-map-leak.js +++ b/test/parallel/test-domain-async-id-map-leak.js @@ -1,7 +1,8 @@ // Flags: --expose-gc 'use strict'; const common = require('../common'); -const onGC = require('../common/ongc'); +const { onGC } = require('../common/gc'); +const { gcUntil } = require('../common/gc'); const assert = require('assert'); const async_hooks = require('async_hooks'); const domain = require('domain'); @@ -40,7 +41,7 @@ d.run(() => { d = null; async function main() { - await common.gcUntil( + await gcUntil( 'All objects garbage collected', () => resourceGCed && domainGCed && emitterGCed); } diff --git a/test/parallel/test-gc-http-client-connaborted.js b/test/parallel/test-gc-http-client-connaborted.js index e9282653f2c132..93ca8ee4de59f1 100644 --- a/test/parallel/test-gc-http-client-connaborted.js +++ b/test/parallel/test-gc-http-client-connaborted.js @@ -4,7 +4,7 @@ // but aborting every connection that comes in. const common = require('../common'); -const onGC = require('../common/ongc'); +const { onGC } = require('../common/gc'); const http = require('http'); const os = require('os'); diff --git a/test/parallel/test-gc-net-timeout.js b/test/parallel/test-gc-net-timeout.js index dfb2bbfd92ac55..c4f74b34b79ec9 100644 --- a/test/parallel/test-gc-net-timeout.js +++ b/test/parallel/test-gc-net-timeout.js @@ -4,7 +4,7 @@ // but using a net server/client instead require('../common'); -const onGC = require('../common/ongc'); +const { onGC } = require('../common/gc'); const assert = require('assert'); const net = require('net'); const os = require('os'); diff --git a/test/parallel/test-gc-tls-external-memory.js b/test/parallel/test-gc-tls-external-memory.js index 752986019e0362..dcf38e11f6c6bf 100644 --- a/test/parallel/test-gc-tls-external-memory.js +++ b/test/parallel/test-gc-tls-external-memory.js @@ -9,7 +9,7 @@ if (!common.hasCrypto) common.skip('missing crypto'); const { duplexPair } = require('stream'); -const onGC = require('../common/ongc'); +const { onGC } = require('../common/gc'); const assert = require('assert'); const tls = require('tls'); diff --git a/test/parallel/test-http-server-connections-checking-leak.js b/test/parallel/test-http-server-connections-checking-leak.js index e28cf117c65f87..282c9a569fba7d 100644 --- a/test/parallel/test-http-server-connections-checking-leak.js +++ b/test/parallel/test-http-server-connections-checking-leak.js @@ -5,7 +5,7 @@ // Check that creating a server without listening does not leak resources. require('../common'); -const onGC = require('../common/ongc'); +const { onGC } = require('../common/gc'); const Countdown = require('../common/countdown'); const http = require('http'); diff --git a/test/parallel/test-http-server-keepalive-req-gc.js b/test/parallel/test-http-server-keepalive-req-gc.js index 93310847d670a7..3bfb6c9600cc24 100644 --- a/test/parallel/test-http-server-keepalive-req-gc.js +++ b/test/parallel/test-http-server-keepalive-req-gc.js @@ -1,7 +1,7 @@ // Flags: --expose-gc 'use strict'; const common = require('../common'); -const onGC = require('../common/ongc'); +const { onGC } = require('../common/gc'); const { createServer } = require('http'); const { connect } = require('net'); diff --git a/test/parallel/test-https-server-connections-checking-leak.js b/test/parallel/test-https-server-connections-checking-leak.js index 3e7c45e4660ed4..e920c8e403705f 100644 --- a/test/parallel/test-https-server-connections-checking-leak.js +++ b/test/parallel/test-https-server-connections-checking-leak.js @@ -10,7 +10,7 @@ if (!common.hasCrypto) { common.skip('missing crypto'); } -const onGC = require('../common/ongc'); +const { onGC } = require('../common/gc'); const Countdown = require('../common/countdown'); const https = require('https'); diff --git a/test/parallel/test-internal-util-weakreference.js b/test/parallel/test-internal-util-weakreference.js index ef3c0943b1f83e..0ecef956a44ab4 100644 --- a/test/parallel/test-internal-util-weakreference.js +++ b/test/parallel/test-internal-util-weakreference.js @@ -1,6 +1,7 @@ // Flags: --expose-internals --expose-gc 'use strict'; -const common = require('../common'); +require('../common'); +const { gcUntil } = require('../common/gc'); const assert = require('assert'); const { WeakReference } = require('internal/util'); @@ -10,7 +11,7 @@ assert.strictEqual(ref.get(), obj); async function main() { obj = null; - await common.gcUntil( + await gcUntil( 'Reference is garbage collected', () => ref.get() === undefined); } diff --git a/test/parallel/test-net-connect-memleak.js b/test/parallel/test-net-connect-memleak.js index 2f06e56e1f631e..84f643746838b6 100644 --- a/test/parallel/test-net-connect-memleak.js +++ b/test/parallel/test-net-connect-memleak.js @@ -23,7 +23,7 @@ // Flags: --expose-gc const common = require('../common'); -const onGC = require('../common/ongc'); +const { onGC } = require('../common/gc'); const assert = require('assert'); const net = require('net'); diff --git a/test/parallel/test-primitive-timer-leak.js b/test/parallel/test-primitive-timer-leak.js index 45681af33d37e5..d590a0347b9cac 100644 --- a/test/parallel/test-primitive-timer-leak.js +++ b/test/parallel/test-primitive-timer-leak.js @@ -1,7 +1,7 @@ 'use strict'; // Flags: --expose-gc require('../common'); -const onGC = require('../common/ongc'); +const { onGC } = require('../common/gc'); // See https://github.com/nodejs/node/issues/53335 const poller = setInterval(() => { diff --git a/test/parallel/test-tls-connect-memleak.js b/test/parallel/test-tls-connect-memleak.js index b0dedfa0bba56d..5bdcbe89f785f6 100644 --- a/test/parallel/test-tls-connect-memleak.js +++ b/test/parallel/test-tls-connect-memleak.js @@ -26,7 +26,7 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); -const onGC = require('../common/ongc'); +const { onGC } = require('../common/gc'); const assert = require('assert'); const tls = require('tls'); const fixtures = require('../common/fixtures'); diff --git a/test/parallel/test-v8-serialize-leak.js b/test/parallel/test-v8-serialize-leak.js index ce0a06196e9fb1..dd51a879efffcb 100644 --- a/test/parallel/test-v8-serialize-leak.js +++ b/test/parallel/test-v8-serialize-leak.js @@ -2,6 +2,7 @@ // Flags: --expose-gc const common = require('../common'); +const { gcUntil } = require('../common/gc'); // On IBMi, the rss memory always returns zero if (common.isIBMi) @@ -16,7 +17,7 @@ for (let i = 0; i < 1000000; i++) { } async function main() { - await common.gcUntil('RSS should go down', () => { + await gcUntil('RSS should go down', () => { const after = process.memoryUsage.rss(); if (common.isASan) { console.log(`ASan: before=${before} after=${after}`); diff --git a/test/parallel/test-zlib-invalid-input-memory.js b/test/parallel/test-zlib-invalid-input-memory.js index d626e6e5b8df38..9761e4bbf097d8 100644 --- a/test/parallel/test-zlib-invalid-input-memory.js +++ b/test/parallel/test-zlib-invalid-input-memory.js @@ -1,7 +1,7 @@ // Flags: --expose-gc 'use strict'; const common = require('../common'); -const onGC = require('../common/ongc'); +const { onGC } = require('../common/gc'); const assert = require('assert'); const zlib = require('zlib'); diff --git a/test/sequential/test-gc-http-client-onerror.js b/test/sequential/test-gc-http-client-onerror.js index 7574c0f9373634..95e65ae0db6721 100644 --- a/test/sequential/test-gc-http-client-onerror.js +++ b/test/sequential/test-gc-http-client-onerror.js @@ -4,7 +4,7 @@ // but with an on('error') handler that does nothing. const common = require('../common'); -const onGC = require('../common/ongc'); +const { onGC } = require('../common/gc'); const cpus = require('os').availableParallelism(); diff --git a/test/sequential/test-gc-http-client-timeout.js b/test/sequential/test-gc-http-client-timeout.js index 02913e178ad89e..e88578e765a7c7 100644 --- a/test/sequential/test-gc-http-client-timeout.js +++ b/test/sequential/test-gc-http-client-timeout.js @@ -3,7 +3,7 @@ // Like test-gc-http-client.js, but with a timeout set. const common = require('../common'); -const onGC = require('../common/ongc'); +const { onGC } = require('../common/gc'); const http = require('http'); function serverHandler(req, res) { diff --git a/test/sequential/test-gc-http-client.js b/test/sequential/test-gc-http-client.js index 8e9d3e9e729db2..b072d2c179b0e8 100644 --- a/test/sequential/test-gc-http-client.js +++ b/test/sequential/test-gc-http-client.js @@ -3,7 +3,7 @@ // just a simple http server and client. const common = require('../common'); -const onGC = require('../common/ongc'); +const { onGC } = require('../common/gc'); const cpus = require('os').availableParallelism();