diff --git a/test/gc/test-http-client-connaborted.js b/test/gc/test-http-client-connaborted.js index 6ff2a282d89c98..30ec63b8852594 100644 --- a/test/gc/test-http-client-connaborted.js +++ b/test/gc/test-http-client-connaborted.js @@ -10,7 +10,6 @@ function serverHandler(req, res) { const http = require('http'); const weak = require('weak'); -const assert = require('assert'); const todo = 500; let done = 0; let count = 0; @@ -28,7 +27,6 @@ function getall() { (function() { function cb(res) { done += 1; - statusLater(); } const req = http.get({ @@ -51,20 +49,11 @@ function afterGC() { countGC++; } -let timer; -function statusLater() { - global.gc(); - if (timer) clearTimeout(timer); - timer = setTimeout(status, 1); -} +setInterval(status, 100).unref(); function status() { global.gc(); console.log('Done: %d/%d', done, todo); console.log('Collected: %d/%d', countGC, count); - if (done === todo) { - console.log('All should be collected now.'); - assert.strictEqual(count, countGC); - process.exit(0); - } + if (countGC === todo) server.close(); } diff --git a/test/gc/test-http-client-onerror.js b/test/gc/test-http-client-onerror.js index b17ab428a2ccd7..aac622b3901b2e 100644 --- a/test/gc/test-http-client-onerror.js +++ b/test/gc/test-http-client-onerror.js @@ -12,7 +12,6 @@ function serverHandler(req, res) { const http = require('http'); const weak = require('weak'); -const assert = require('assert'); const todo = 500; let done = 0; let count = 0; @@ -31,7 +30,6 @@ function getall() { function cb(res) { res.resume(); done += 1; - statusLater(); } function onerror(er) { throw er; @@ -59,20 +57,11 @@ function afterGC() { countGC++; } -let timer; -function statusLater() { - global.gc(); - if (timer) clearTimeout(timer); - timer = setTimeout(status, 1); -} +setInterval(status, 100).unref(); function status() { global.gc(); console.log('Done: %d/%d', done, todo); console.log('Collected: %d/%d', countGC, count); - if (done === todo) { - console.log('All should be collected now.'); - assert.strictEqual(count, countGC); - process.exit(0); - } + if (countGC === todo) server.close(); } diff --git a/test/gc/test-http-client-timeout.js b/test/gc/test-http-client-timeout.js index fb4e8ba0f7058d..2ef54cad79bdfc 100644 --- a/test/gc/test-http-client-timeout.js +++ b/test/gc/test-http-client-timeout.js @@ -14,7 +14,6 @@ function serverHandler(req, res) { const http = require('http'); const weak = require('weak'); -const assert = require('assert'); const todo = 550; let done = 0; let count = 0; @@ -33,7 +32,6 @@ function getall() { function cb(res) { res.resume(); done += 1; - statusLater(); } const req = http.get({ @@ -60,20 +58,11 @@ function afterGC() { countGC++; } -let timer; -function statusLater() { - global.gc(); - if (timer) clearTimeout(timer); - timer = setTimeout(status, 1); -} +setInterval(status, 100).unref(); function status() { global.gc(); console.log('Done: %d/%d', done, todo); console.log('Collected: %d/%d', countGC, count); - if (done === todo) { - console.log('All should be collected now.'); - assert.strictEqual(count, countGC); - process.exit(0); - } + if (countGC === todo) server.close(); } diff --git a/test/gc/test-http-client.js b/test/gc/test-http-client.js index f81cab0b09d2c2..03c159fa24f76e 100644 --- a/test/gc/test-http-client.js +++ b/test/gc/test-http-client.js @@ -10,7 +10,6 @@ function serverHandler(req, res) { const http = require('http'); const weak = require('weak'); -const assert = require('assert'); const todo = 500; let done = 0; let count = 0; @@ -54,15 +53,11 @@ function afterGC() { countGC++; } -setInterval(status, 1000).unref(); +setInterval(status, 100).unref(); function status() { global.gc(); console.log('Done: %d/%d', done, todo); console.log('Collected: %d/%d', countGC, count); - if (done === todo) { - console.log('All should be collected now.'); - assert.strictEqual(count, countGC); - process.exit(0); - } + if (countGC === todo) server.close(); } diff --git a/test/gc/test-net-timeout.js b/test/gc/test-net-timeout.js index b8ea8e2089c439..ce71f4d9e8be82 100644 --- a/test/gc/test-net-timeout.js +++ b/test/gc/test-net-timeout.js @@ -62,14 +62,5 @@ function status() { global.gc(); console.log('Done: %d/%d', done, todo); console.log('Collected: %d/%d', countGC, count); - if (done === todo) { - /* Give libuv some time to make close callbacks. */ - setTimeout(function() { - global.gc(); - console.log('All should be collected now.'); - console.log('Collected: %d/%d', countGC, count); - assert.strictEqual(count, countGC); - process.exit(0); - }, 200); - } + if (countGC === todo) server.close(); }