0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-net-server-close-before-ipc-response.js
theanarkh 29ec7e9331
lib: make sure close net server
PR-URL: https://github.com/nodejs/node/pull/51929
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
2024-03-03 10:29:15 +00:00

23 lines
541 B
JavaScript

'use strict';
const common = require('../common');
const net = require('net');
const cluster = require('cluster');
// Process should exit
if (cluster.isPrimary) {
cluster.fork();
} else {
const send = process.send;
process.send = function(message) {
// listenOnPrimaryHandle in net.js should call handle.close()
if (message.act === 'close') {
setImmediate(() => {
process.disconnect();
});
}
return send.apply(this, arguments);
};
net.createServer().listen(0, common.mustNotCall()).close();
}