From fb32f3eaff27306b25d19a9a2bca56989f3d5f79 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 15 Nov 2020 08:16:14 -0800 Subject: [PATCH] test: make test-http2-client-jsstream-destroy.js reliable Use events instead of setTimeout() calls. Fixes: https://github.com/nodejs/node/issues/36078 PR-URL: https://github.com/nodejs/node/pull/36129 Reviewed-By: Antoine du Hamel Reviewed-By: Benjamin Gruenbaum --- test/parallel/test-http2-client-jsstream-destroy.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-http2-client-jsstream-destroy.js b/test/parallel/test-http2-client-jsstream-destroy.js index f881eac47aa809..7e44241e985a64 100644 --- a/test/parallel/test-http2-client-jsstream-destroy.js +++ b/test/parallel/test-http2-client-jsstream-destroy.js @@ -46,10 +46,13 @@ server.listen(0, common.mustCall(function() { }); const req = client.request(); - setTimeout(() => socket.destroy(), common.platformTimeout(100)); - setTimeout(() => client.close(), common.platformTimeout(200)); - setTimeout(() => server.close(), common.platformTimeout(300)); + server.on('request', () => { + socket.destroy(); + }); - req.on('close', common.mustCall(() => { })); + req.on('close', common.mustCall(() => { + client.close(); + server.close(); + })); }); }));