mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 22:56:06 +00:00

Race condition caused occasional failure on CI. Chained callbacks used to remove race condition. PR-URL: https://github.com/nodejs/node/pull/10293 Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
31 lines
638 B
JavaScript
31 lines
638 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const http = require('http');
|
|
|
|
const options = {
|
|
method: 'GET',
|
|
port: undefined,
|
|
host: '127.0.0.1',
|
|
path: '/'
|
|
};
|
|
|
|
const server = http.createServer();
|
|
|
|
server.listen(0, options.host, function() {
|
|
options.port = this.address().port;
|
|
const req = http.request(options);
|
|
req.on('error', function() {
|
|
// this space is intentionally left blank
|
|
});
|
|
req.on('close', common.mustCall(() => server.close()));
|
|
|
|
req.setTimeout(1);
|
|
req.on('timeout', common.mustCall(() => {
|
|
req.end(() => {
|
|
setTimeout(() => {
|
|
req.destroy();
|
|
}, 100);
|
|
});
|
|
}));
|
|
});
|