mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
test-http-exit-delay was introduced to confirm the removal of a 1 second delay that can occur when exiting node after an http request. This change refactors the test for simplicity and also in the hopes of either eliminating flakiness on CI or, if not that, at least making the source of the flakiness easier to track down. Ref: https://github.com/nodejs/node/commit/16b59cbc Fixes: https://github.com/nodejs/node/issues/4045 PR-URL: https://github.com/nodejs/node/pull/4055 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
31 lines
678 B
JavaScript
31 lines
678 B
JavaScript
'use strict';
|
|
const assert = require('assert');
|
|
const common = require('../common');
|
|
const http = require('http');
|
|
|
|
var start;
|
|
const server = http.createServer(common.mustCall(function(req, res) {
|
|
req.resume();
|
|
req.on('end', function() {
|
|
res.end('Success');
|
|
});
|
|
|
|
server.close();
|
|
}));
|
|
|
|
server.listen(common.PORT, 'localhost', common.mustCall(function() {
|
|
start = new Date();
|
|
const req = http.request({
|
|
'host': 'localhost',
|
|
'port': common.PORT,
|
|
'agent': false,
|
|
'method': 'PUT'
|
|
});
|
|
req.end('Test');
|
|
}));
|
|
|
|
process.on('exit', function() {
|
|
const end = new Date();
|
|
assert(end - start < 1000, 'Entire test should take less than one second');
|
|
});
|