Skip to content

Commit

Permalink
test: make test-http2-client-jsstream-destroy.js reliable
Browse files Browse the repository at this point in the history
Use events instead of setTimeout() calls.

Fixes: #36078

PR-URL: #36129
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
  • Loading branch information
Trott authored and codebytere committed Nov 22, 2020
1 parent c19df17 commit f9bbd35
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions test/parallel/test-http2-client-jsstream-destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}));
});
}));

0 comments on commit f9bbd35

Please sign in to comment.