File tree Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Expand file tree Collapse file tree 2 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -174,19 +174,18 @@ node:internal/child_process:388
174174 ^
175175Error: Access to this API has been restricted
176176 at ChildProcess.spawn (node:internal/child_process:388:28)
177- at Object.spawn (node:child_process:723:9)
178- at Object.<anonymous> (/home/index.js:3:14)
179- at Module._compile (node:internal/modules/cjs/loader:1120:14)
180- at Module._extensions..js (node:internal/modules/cjs/loader:1174:10)
181- at Module.load (node:internal/modules/cjs/loader:998:32)
182- at Module._load (node:internal/modules/cjs/loader:839:12)
183- at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
184177 at node:internal/main/run_main_module:17:47 {
185178 code: 'ERR_ACCESS_DENIED',
186179 permission: 'ChildProcess'
187180}
188181```
189182
183+ Unlike ` child_process.spawn ` , the ` child_process.fork ` API copies the execution
184+ arguments from the parent process. This means that if you start Node.js with the
185+ Permission Model enabled and include the ` --allow-child-process ` flag, calling
186+ ` child_process.fork() ` will propagate all Permission Model flags to the child
187+ process.
188+
190189### ` --allow-fs-read `
191190
192191<!-- YAML
Original file line number Diff line number Diff line change @@ -5,8 +5,15 @@ const common = require('../common');
55common . skipIfWorker ( ) ;
66const assert = require ( 'assert' ) ;
77const childProcess = require ( 'child_process' ) ;
8+ const fs = require ( 'fs' ) ;
89
910if ( process . argv [ 2 ] === 'child' ) {
11+ assert . throws ( ( ) => {
12+ fs . writeFileSync ( __filename , 'should not write' ) ;
13+ } , common . expectsError ( {
14+ code : 'ERR_ACCESS_DENIED' ,
15+ permission : 'FileSystemWrite' ,
16+ } ) ) ;
1017 process . exit ( 0 ) ;
1118}
1219
@@ -21,6 +28,7 @@ if (process.argv[2] === 'child') {
2128 // doesNotThrow
2229 childProcess . spawnSync ( process . execPath , [ '--version' ] ) ;
2330 childProcess . execSync ( ...common . escapePOSIXShell `"${ process . execPath } " --version` ) ;
24- childProcess . fork ( __filename , [ 'child' ] ) ;
31+ const child = childProcess . fork ( __filename , [ 'child' ] ) ;
32+ child . on ( 'close' , common . mustCall ( ) ) ;
2533 childProcess . execFileSync ( process . execPath , [ '--version' ] ) ;
2634}
You can’t perform that action at this time.
0 commit comments