GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — cluster: fix inspector port assignment · nodejs/node@bf4d074

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/cluster
    • master.js
  • test/sequential
    • test-inspector-port-cluster.js
    • test-inspector-port-zero-cluster.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/cluster/master.js‎

Copy file name to clipboardExpand all lines: lib/internal/cluster/master.js
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const intercom = new EventEmitter();
1414
const SCHED_NONE = 1;
1515
const SCHED_RR = 2;
1616
const { isLegalPort } = require('internal/net');
17+
const [ minPort, maxPort ] = [ 1024, 65535 ];
1718

1819
module.exports = cluster;
1920

@@ -119,6 +120,8 @@ function createWorkerProcess(id, env) {
119120
}
120121
} else {
121122
inspectPort = process.debugPort + debugPortOffset;
123+
if (inspectPort > maxPort)
124+
inspectPort = inspectPort - maxPort + minPort - 1;
122125
debugPortOffset++;
123126
}
124127

Collapse file

‎test/sequential/test-inspector-port-cluster.js‎

Copy file name to clipboardExpand all lines: test/sequential/test-inspector-port-cluster.js
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,16 @@ function testRunnerMain() {
2424
workers: [{ expectedPort: 9230 }]
2525
});
2626

27+
spawnMaster({
28+
execArgv: ['--inspect=65534'],
29+
workers: [
30+
{ expectedPort: 65535 },
31+
{ expectedPort: 1024 },
32+
{ expectedPort: 1025 },
33+
{ expectedPort: 1026 }
34+
]
35+
});
36+
2737
let port = debuggerPort + offset++ * 5;
2838

2939
spawnMaster({
Collapse file

‎test/sequential/test-inspector-port-zero-cluster.js‎

Copy file name to clipboardExpand all lines: test/sequential/test-inspector-port-zero-cluster.js
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,14 @@ function serialFork() {
3030
if (cluster.isMaster) {
3131
Promise.all([serialFork(), serialFork(), serialFork()])
3232
.then(common.mustCall((ports) => {
33-
ports.push(process.debugPort);
34-
ports.sort();
33+
ports.splice(0, 0, process.debugPort);
3534
// 4 = [master, worker1, worker2, worker3].length()
3635
assert.strictEqual(ports.length, 4);
3736
assert(ports.every((port) => port > 0));
3837
assert(ports.every((port) => port < 65536));
39-
// Ports should be consecutive.
40-
assert.strictEqual(ports[0] + 1, ports[1]);
41-
assert.strictEqual(ports[1] + 1, ports[2]);
42-
assert.strictEqual(ports[2] + 1, ports[3]);
38+
assert.strictEqual(ports[0] === 65535 ? 1024 : ports[0] + 1, ports[1]);
39+
assert.strictEqual(ports[1] === 65535 ? 1024 : ports[1] + 1, ports[2]);
40+
assert.strictEqual(ports[2] === 65535 ? 1024 : ports[2] + 1, ports[3]);
4341
}))
4442
.catch(
4543
(err) => {

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.