node/test/parallel/test-http-server-drop-connections-in-cluster.js
Meghan Denny 553f236865
test: rename test-net-server-drop-connections-in-cluster.js to -http-
PR-URL: https://github.com/nodejs/node/pull/59532
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2025-08-21 19:38:09 +00:00

22 lines
681 B
JavaScript

'use strict';
const common = require('../common');
const cluster = require('cluster');
const http = require('http');
if (cluster.isPrimary) {
cluster.fork();
} else {
const server = http.createServer();
server.maxConnections = 0;
server.dropMaxConnection = true;
// When dropMaxConnection is false, the main process will continue to
// distribute the request to the child process, if true, the child will
// close the connection directly and emit drop event.
server.on('drop', common.mustCall((a) => {
process.exit();
}));
server.listen(common.mustCall(() => {
http.get(`http://localhost:${server.address().port}`).on('error', console.error);
}));
}