Description
Since net._setSimultaneousAccepts() is deprecated (DEP0121) and has reached End-of-Life status, we should provide a codemod to replace it.
- The codemod should remove calls to
net._setSimultaneousAccepts() as it was an internal API.
- The codemod should handle both CommonJS and ESM imports.
- The codemod should suggest alternative approaches for connection handling if needed.
- The codemod should remove this internal API usage completely.
Additional Information
Note that net._setSimultaneousAccepts() was removed in Node.js v24.0.0. The function was deprecated because it was an internal API that was never intended for public use. This function controlled how many connections could be accepted simultaneously on Windows, but this behavior is now handled automatically by Node.js.
The net._setSimultaneousAccepts() function was part of the internal networking implementation and its usage was not recommended or documented for public consumption.
Examples
Example 1: Remove internal API call
Before:
const net = require("node:net");
net._setSimultaneousAccepts(false);
const server = net.createServer();
After:
const net = require("node:net");
const server = net.createServer();
Example 2: Remove from server initialization
Before:
const net = require("node:net");
function createServer() {
net._setSimultaneousAccepts(true);
return net.createServer((socket) => {
// handle connection
});
}
After:
const net = require("node:net");
function createServer() {
return net.createServer((socket) => {
// handle connection
});
}
Example 3: Remove from module setup
Before:
const net = require("node:net");
net._setSimultaneousAccepts(false);
module.exports = {
createServer: () => net.createServer()
};
After:
const net = require("node:net");
module.exports = {
createServer: () => net.createServer()
};
Example 4: Remove from application startup
Before:
const net = require("node:net");
function initializeApp() {
net._setSimultaneousAccepts(true);
const server = net.createServer();
server.listen(3000);
}
After:
const net = require("node:net");
function initializeApp() {
const server = net.createServer();
server.listen(3000);
}
Example 5: ESM import cleanup
Before:
import net from "node:net";
net._setSimultaneousAccepts(false);
const server = net.createServer();
After:
import net from "node:net";
const server = net.createServer();
Example 6: Remove from configuration
Before:
const net = require("node:net");
const config = {
simultaneousAccepts: false,
port: 8080
};
function setupServer(config) {
net._setSimultaneousAccepts(config.simultaneousAccepts);
return net.createServer().listen(config.port);
}
After:
const net = require("node:net");
const config = {
port: 8080
};
function setupServer(config) {
return net.createServer().listen(config.port);
}
Refs
Description
Since
net._setSimultaneousAccepts()is deprecated (DEP0121) and has reached End-of-Life status, we should provide a codemod to replace it.net._setSimultaneousAccepts()as it was an internal API.Additional Information
Note that
net._setSimultaneousAccepts()was removed in Node.js v24.0.0. The function was deprecated because it was an internal API that was never intended for public use. This function controlled how many connections could be accepted simultaneously on Windows, but this behavior is now handled automatically by Node.js.The
net._setSimultaneousAccepts()function was part of the internal networking implementation and its usage was not recommended or documented for public consumption.Examples
Example 1: Remove internal API call
Before:
After:
Example 2: Remove from server initialization
Before:
After:
Example 3: Remove from module setup
Before:
After:
Example 4: Remove from application startup
Before:
After:
Example 5: ESM import cleanup
Before:
After:
Example 6: Remove from configuration
Before:
After:
Refs
net._setSimultaneousAccepts()