Skip to content

Commit 03fcd8b

Browse files
yunshingngRafaelGSS
authored andcommitted
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> PR-URL: #66124 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
1 parent 305cfcd commit 03fcd8b

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
@@ -338,7 +338,13 @@ easy to configure permissions as needed when using `npx`.
338338

339339
There are constraints you need to know before using this system:
340340

341-
* The model does not inherit to a worker thread.
341+
* The model does not inherit to a worker thread. A default
342+
`worker_threads.Worker` (no `execArgv` option) still receives the parent
343+
process CLI flags, including `--permission` and `--allow-*` if those were
344+
passed to the parent. Setting `execArgv` explicitly, including
345+
`execArgv: []`, replaces the inherited flags. The worker then does not keep
346+
the parent's Permission Model grants unless those flags are listed again in
347+
`execArgv`. That difference is intended, not a bypass.
342348
* When using the Permission Model the following features will be restricted:
343349
* Native modules
344350
* Network

‎doc/api/worker_threads.md‎

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

0 commit comments

Comments
 (0)