test: fix flaky http-client-timeout-agent
Close the connection immediately after receiving the `end` event to avoid that the `timeout` event is fired before the connection closes gracefully. Move the test back to parallel. PR-URL: https://github.com/nodejs/node/pull/19856 Fixes: https://github.com/nodejs/node/issues/19804 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
parent
87880466b1
commit
5b8c62c60d
@ -46,11 +46,10 @@ const server = http.createServer(function(req, res) {
|
|||||||
|
|
||||||
server.listen(0, options.host, function() {
|
server.listen(0, options.host, function() {
|
||||||
options.port = this.address().port;
|
options.port = this.address().port;
|
||||||
let req;
|
|
||||||
|
|
||||||
for (requests_sent = 0; requests_sent < 30; requests_sent += 1) {
|
for (requests_sent = 0; requests_sent < 30; requests_sent += 1) {
|
||||||
options.path = `/${requests_sent}`;
|
options.path = `/${requests_sent}`;
|
||||||
req = http.request(options);
|
const req = http.request(options);
|
||||||
req.id = requests_sent;
|
req.id = requests_sent;
|
||||||
req.on('response', function(res) {
|
req.on('response', function(res) {
|
||||||
res.on('data', function(data) {
|
res.on('data', function(data) {
|
||||||
@ -59,6 +58,7 @@ server.listen(0, options.host, function() {
|
|||||||
res.on('end', function(data) {
|
res.on('end', function(data) {
|
||||||
console.log(`res#${this.req.id} end`);
|
console.log(`res#${this.req.id} end`);
|
||||||
requests_done += 1;
|
requests_done += 1;
|
||||||
|
req.destroy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
req.on('close', function() {
|
req.on('close', function() {
|
Loading…
x
Reference in New Issue
Block a user