Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,8 @@ For information about the governance of the Node.js project, see
**Vladimir Morozov** <<vmorozov@microsoft.com>> (he/him)
* [VoltrexKeyva](https://github.com/VoltrexKeyva) -
**Mohammed Keyvanzadeh** <<mohammadkeyvanzade94@gmail.com>> (he/him)
* [watilde](https://github.com/watilde) -
**Daijiro Wachi** <<daijiro.wachi@gmail.com>> (he/him)
* [zcbenz](https://github.com/zcbenz) -
**Cheng Zhao** <<zcbenz@gmail.com>> (he/him)
* [ZYSzys](https://github.com/ZYSzys) -
Expand Down Expand Up @@ -717,8 +719,6 @@ For information about the governance of the Node.js project, see
**Vladimir Kurchatkin** <<vladimir.kurchatkin@gmail.com>>
* [vsemozhetbyt](https://github.com/vsemozhetbyt) -
**Vse Mozhet Byt** <<vsemozhetbyt@gmail.com>> (he/him)
* [watilde](https://github.com/watilde) -
**Daijiro Wachi** <<daijiro.wachi@gmail.com>> (he/him)
* [watson](https://github.com/watson) -
**Thomas Watson** <<w@tson.dk>>
* [whitlockjc](https://github.com/whitlockjc) -
Expand Down
6 changes: 0 additions & 6 deletions doc/changelogs/CHANGELOG_V20.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,11 @@ This is a security release.

### Notable Changes

lib:

* (CVE-2025-55132) disable futimes when permission model is enabled (RafaelGSS) <https://github.com/nodejs-private/node-private/pull/802>
* (CVE-2025-59465) add TLSSocket default error handler (RafaelGSS) <https://github.com/nodejs-private/node-private/pull/797>
lib,permission:
* (CVE-2025-55130) require full read and write to symlink APIs (RafaelGSS) <https://github.com/nodejs-private/node-private/pull/760>
src:
* (CVE-2025-59466) rethrow stack overflow exceptions in async\_hooks (Matteo Collina) <https://github.com/nodejs-private/node-private/pull/773>
src,lib:
* (CVE-2025-55131) refactor unsafe buffer creation to remove zero-fill toggle (Сковорода Никита Андреевич) <https://github.com/nodejs-private/node-private/pull/759>
tls:
* (CVE-2026-21637) route callback exceptions through error handlers (Matteo Collina) <https://github.com/nodejs-private/node-private/pull/796>

### Commits
Expand Down
6 changes: 0 additions & 6 deletions doc/changelogs/CHANGELOG_V22.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,11 @@ This is a security release.

### Notable Changes

lib:

* (CVE-2025-59465) add TLSSocket default error handler
* (CVE-2025-55132) disable futimes when permission model is enabled
lib,permission:
* (CVE-2025-55130) require full read and write to symlink APIs
src:
* (CVE-2025-59466) rethrow stack overflow exceptions in async\_hooks
src,lib:
* (CVE-2025-55131) refactor unsafe buffer creation to remove zero-fill toggle
tls:
* (CVE-2026-21637) route callback exceptions through error handlers

### Commits
Expand Down
6 changes: 0 additions & 6 deletions doc/changelogs/CHANGELOG_V24.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,11 @@ This is a security release.

### Notable Changes

lib:

* (CVE-2025-59465) add TLSSocket default error handler (RafaelGSS) <https://github.com/nodejs-private/node-private/pull/797>
* (CVE-2025-55132) disable futimes when permission model is enabled (RafaelGSS) <https://github.com/nodejs-private/node-private/pull/748>
lib,permission:
* (CVE-2025-55130) require full read and write to symlink APIs (RafaelGSS) <https://github.com/nodejs-private/node-private/pull/760>
src:
* (CVE-2025-59466) rethrow stack overflow exceptions in async\_hooks (Matteo Collina) <https://github.com/nodejs-private/node-private/pull/773>
src,lib:
* (CVE-2025-55131) refactor unsafe buffer creation to remove zero-fill toggle (Сковорода Никита Андреевич) <https://github.com/nodejs-private/node-private/pull/759>
tls:
* (CVE-2026-21637) route callback exceptions through error handlers (Matteo Collina) <https://github.com/nodejs-private/node-private/pull/796>

### Commits
Expand Down
6 changes: 0 additions & 6 deletions doc/changelogs/CHANGELOG_V25.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,12 @@ This is a security release.

### Notable Changes

lib:

* (CVE-2025-59465) add TLSSocket default error handler (RafaelGSS) <https://github.com/nodejs-private/node-private/pull/750>
permission:
* (CVE-2026-21636) add network check on pipe\_wrap connect (RafaelGSS) <https://github.com/nodejs-private/node-private/pull/784>
* (CVE-2025-55130) require full read and write to symlink APIs (RafaelGSS) <https://github.com/nodejs-private/node-private/pull/760>
* (CVE-2025-55132) disable futimes when permission model is enabled (RafaelGSS) <https://github.com/nodejs-private/node-private/pull/748>
src:
* (CVE-2025-59466) rethrow stack overflow exceptions in async\_hooks (Matteo Collina) <https://github.com/nodejs-private/node-private/pull/773>
src,lib:
* (CVE-2025-55131) refactor unsafe buffer creation to remove zero-fill toggle (Сковорода Никита Андреевич) <https://github.com/nodejs-private/node-private/pull/759>
tls:
* (CVE-2026-21637) route callback exceptions through error handlers (Matteo Collina) <https://github.com/nodejs-private/node-private/pull/790>

### Commits
Expand Down
25 changes: 17 additions & 8 deletions lib/internal/cluster/primary.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,12 @@ function queryServer(worker, message) {
return;

const key = `${message.address}:${message.port}:${message.addressType}:` +
`${message.fd}:${message.index}`;
let handle = handles.get(key);
`${message.fd}` + (message.port === 0 ? `:${message.index}` : '');
const cachedHandle = handles.get(key);
let handle;
if (cachedHandle && !cachedHandle.has(worker)) {
handle = cachedHandle;
}

if (handle === undefined) {
let address = message.address;
Expand All @@ -298,25 +302,30 @@ function queryServer(worker, message) {
handle = new RoundRobinHandle(key, address, message);
}

handles.set(key, handle);
if (!cachedHandle) {
handles.set(key, handle);
}
}

handle.data ||= message.data;

// Set custom server data
handle.add(worker, (errno, reply, handle) => {
handle.add(worker, (errno, reply, serverHandle) => {
if (!errno) {
handles.set(key, handle); // Update in case it was replaced.
}
const { data } = handles.get(key);

if (errno)
handles.delete(key); // Gives other workers a chance to retry.
if (!cachedHandle && errno) {
handles.delete(key);
}

send(worker, {
errno,
key,
ack: message.seq,
data,
...reply,
}, handle);
}, serverHandle);
});
}

Expand Down
4 changes: 4 additions & 0 deletions lib/internal/cluster/round_robin_handle.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,7 @@ RoundRobinHandle.prototype.handoff = function(worker) {
this.handoff(worker);
});
};

RoundRobinHandle.prototype.has = function(worker) {
return this.all.has(worker.id);
};
4 changes: 4 additions & 0 deletions lib/internal/cluster/shared_handle.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ SharedHandle.prototype.remove = function(worker) {
this.handle = null;
return true;
};

SharedHandle.prototype.has = function(worker) {
return this.workers.has(worker.id);
};
93 changes: 93 additions & 0 deletions test/sequential/test-cluster-port-reuse-between-workers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
'use strict';

const common = require('../common');
const cluster = require('cluster');
const assert = require('assert');

const acts = {
WORKER1_SERVER1_CLOSED: { cmd: 'WORKER1_SERVER1_CLOSED' },
WORKER2_SERVER1_STARTED: { cmd: 'WORKER2_SERVER1_STARTED' },
WORKER1_SERVER2_CLOSED: { cmd: 'WORKER1_SERVER2_CLOSED' },
};

if (cluster.isMaster) {
const currentHost = '::';
const worker1 = cluster.fork({
WORKER_ID: 'worker1',
HOST: currentHost,
});
let worker2;
worker1.on('error', common.mustNotCall());
worker1.on('message', onMessage);

function createWorker2() {
worker2 = cluster.fork({
WORKER_ID: 'worker2',
HOST: currentHost,
});
worker2.on('error', common.mustNotCall());
worker2.on('message', onMessage);
}

function onMessage(msg) {
switch (msg.cmd) {
case acts.WORKER1_SERVER1_CLOSED.cmd:
createWorker2();
break;
case acts.WORKER2_SERVER1_STARTED.cmd:
worker1.send(acts.WORKER2_SERVER1_STARTED);
break;
case acts.WORKER1_SERVER2_CLOSED.cmd:
worker1.kill();
worker2.kill();
break;
default:
assert.fail(`Unexpected message ${msg.cmd}`);
}
}
} else {
const WORKER_ID = process.env.WORKER_ID;
function createServer() {
return new Promise((resolve, reject) => {
const net = require('net');
const PORT = 8000;
const server = net
.createServer((socket) => {
socket.end(
`Handled by worker ${process.env.WORKER_ID} (${process.pid})\n`
);
})
.on('error', (e) => {
reject(e);
});

server.listen(
{
port: PORT,
host: process.env.HOST,
},
() => resolve(server)
);
});
}
(async () => {
const server1 = await createServer();
if (WORKER_ID === 'worker2') {
process.send(acts.WORKER2_SERVER1_STARTED);
} else {
await createServer().catch(common.mustCall());
await new Promise((r) => server1.close(r));
process.send(acts.WORKER1_SERVER1_CLOSED);

process.on('message', async (msg) => {
if (msg.cmd === acts.WORKER2_SERVER1_STARTED.cmd) {
const server2 = await createServer();
await new Promise((r) => server2.close(r));
process.send(acts.WORKER1_SERVER2_CLOSED);
} else {
assert.fail(`Unexpected message ${msg.cmd}`);
}
});
}
})().then(common.mustCall());
}
Loading