mirror of
https://github.com/nodejs/node.git
synced 2025-05-18 13:33:10 +00:00

Windows is still sometimes failing with ECONNRESET. Bring back the handling of this error as was initially introduced in PR #4442. PR-URL: https://github.com/nodejs/node/pull/5179 Reviewed-By: Rich Trott <rtrott@gmail.com> Fixes: https://github.com/nodejs/node/issues/3635
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
|
|
const cluster = require('cluster');
|
|
const net = require('net');
|
|
|
|
if (!cluster.isMaster) {
|
|
// Exit on first received handle to leave the queue non-empty in master
|
|
process.on('message', function() {
|
|
process.exit(1);
|
|
});
|
|
return;
|
|
}
|
|
|
|
var server = net.createServer(function(s) {
|
|
if (common.isWindows) {
|
|
s.on('error', function(err) {
|
|
// Prevent possible ECONNRESET errors from popping up
|
|
if (err.code !== 'ECONNRESET')
|
|
throw err;
|
|
});
|
|
}
|
|
setTimeout(function() {
|
|
s.destroy();
|
|
}, 100);
|
|
}).listen(common.PORT, function() {
|
|
var worker = cluster.fork();
|
|
|
|
function send(callback) {
|
|
var s = net.connect(common.PORT, function() {
|
|
worker.send({}, s, callback);
|
|
});
|
|
}
|
|
|
|
worker.process.once('close', common.mustCall(function() {
|
|
// Otherwise the crash on `_channel.fd` access may happen
|
|
assert(worker.process._channel === null);
|
|
server.close();
|
|
}));
|
|
|
|
// Send 2 handles to make `process.disconnect()` wait
|
|
send();
|
|
send();
|
|
});
|