Skip to content

Commit a30e532

Browse files
committed
doc: clarify Worker execArgv vs Permission Model grants
Omit execArgv: the worker keeps the parent's CLI flags, including --permission and --allow-*. Explicit execArgv (including []) replaces inheritance and can drop those grants. That is intended. Documented after #65359. No runtime change. Refs: #65359 Signed-off-by: yunshingng <yunshingng25@gmail.com>
1 parent 8b9f89f commit a30e532

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

‎doc/api/permissions.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,13 @@ easy to configure permissions as needed when using `npx`.
330330

331331
There are constraints you need to know before using this system:
332332

333-
* The model does not inherit to a worker thread.
333+
* The model does not inherit to a worker thread. A default
334+
`worker_threads.Worker` (no `execArgv` option) still receives the parent
335+
process CLI flags, including `--permission` and `--allow-*` if those were
336+
passed to the parent. Setting `execArgv` explicitly, including
337+
`execArgv: []`, replaces the inherited flags. The worker then does not keep
338+
the parent's Permission Model grants unless those flags are listed again in
339+
`execArgv`. That difference is intended, not a bypass.
334340
* When using the Permission Model the following features will be restricted:
335341
* Native modules
336342
* Network

‎doc/api/worker_threads.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,6 +1631,12 @@ changes:
16311631
process (such as `--title`) are not supported. If set, this is provided
16321632
as [`process.execArgv`][] inside the worker. By default, options are
16331633
inherited from the parent thread.
1634+
Passing an explicit `execArgv` (including an empty array) replaces that
1635+
inheritance: the worker receives only the listed flags. Under the
1636+
[Permission Model](permissions.md#permission-model), that means an explicit
1637+
`execArgv` can drop the parent's `--permission` / `--allow-*` grants.
1638+
Omit `execArgv` to keep the parent's CLI flags. This is intended. See
1639+
[Permission Model limitations](permissions.md#limitations-and-known-issues).
16341640
* `stdin` {boolean} If this is set to `true`, then `worker.stdin`
16351641
provides a writable stream whose contents appear as `process.stdin`
16361642
inside the Worker. By default, no data is provided.

0 commit comments

Comments
 (0)