| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,5 +21,9 @@ | |||
| 21 | 21 | ||
| 22 | 22 | 'use strict'; | |
| 23 | 23 | ||
| 24 | - const childOrPrimary = 'NODE_UNIQUE_ID' in process.env ? 'child' : 'primary'; | ||
| 24 | + const { | ||
| 25 | + ObjectPrototypeHasOwnProperty: ObjectHasOwn, | ||
| 26 | + } = primordials; | ||
| 27 | + | ||
| 28 | + const childOrPrimary = ObjectHasOwn(process.env, 'NODE_UNIQUE_ID') ? 'child' : 'primary'; | ||
| 25 | 29 | module.exports = require(`internal/cluster/${childOrPrimary}`); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,13 +22,26 @@ | |||
| 22 | 22 | 'use strict'; | |
| 23 | 23 | const common = require('../common'); | |
| 24 | 24 | ||
| 25 | - const assert = require('assert'); | ||
| 26 | - const cluster = require('cluster'); | ||
| 25 | + const assert = require('node:assert'); | ||
| 26 | + const cluster = require('node:cluster'); | ||
| 27 | + const { spawnSync } = require('node:child_process'); | ||
| 27 | 28 | ||
| 28 | 29 | assert.strictEqual('NODE_UNIQUE_ID' in process.env, false, | |
| 29 | 30 | `NODE_UNIQUE_ID (${process.env.NODE_UNIQUE_ID}) ` + | |
| 30 | 31 | 'should be removed on startup'); | |
| 31 | 32 | ||
| 33 | + { | ||
| 34 | + const { status } = spawnSync(process.execPath, [ | ||
| 35 | + '-e', | ||
| 36 | + ` | ||
| 37 | + const { strictEqual } = require('node:assert'); | ||
| 38 | + Object.setPrototypeOf(process.env, { NODE_UNIQUE_ID: 0 }); | ||
| 39 | + strictEqual(require('cluster').isPrimary, true); | ||
| 40 | + `, | ||
| 41 | + ]); | ||
| 42 | + assert.strictEqual(status, 0); | ||
| 43 | + } | ||
| 44 | + | ||
| 32 | 45 | function forEach(obj, fn) { | |
| 33 | 46 | Object.keys(obj).forEach((name, index) => { | |
| 34 | 47 | fn(obj[name], name, index); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments