Skip to content

fix(ext/node): forward permissions when spawning deno with subcommand args - #35443

Merged
bartlomieju merged 1 commit into
mainfrom
fix/forward-perms-deno-subcommand-spawn
Jun 23, 2026
Merged

bartlomieju merged 1 commit into
mainfrom
fix/forward-perms-deno-subcommand-spawn

Conversation

@bartlomieju

Copy link
Copy Markdown
Member

When an npm tool running under Deno spawns a child process that is itself
Deno, the node-compat layer translates the Node.js argv to Deno argv and
grants the child full permissions (-A) so it behaves like a permissionless
Node.js process. That injection was skipped whenever the spawned argv
already started with a Deno subcommand: a tool that detected it was running
under Deno and spawned something like "deno run <script>" had its args
passed through verbatim, dropping the implicit -A. The child then ran with
no permissions and tripped a permission prompt on the first env read (TERM),
which hung because the parent CLI holds stdin in raw mode and the prompt
could never be answered.

This restores Node.js semantics in that pass-through path: when the
subcommand executes user code (run/test/bench/serve) and no explicit
permission flag is present, -A is injected. Callers that pass their own
permission flags (for example vitest workers that spawn "run -A ...") are
left untouched, and detection covers long, short, bundled and =value forms
to mirror the CLI parser.

Fixes #35441

… args (#35441)

When an npm tool running under Deno spawns a child process that is itself
Deno, the node-compat layer translates the Node.js argv to Deno argv and
grants the child full permissions (-A) so it behaves like a permissionless
Node.js process. However, when the spawned argv already started with a Deno
subcommand (e.g. a tool that detected it is running under Deno and spawned
"deno run <script>"), translate_to_deno_args passed the args through verbatim
and dropped the implicit -A.

The child therefore ran with no permissions and hit a permission prompt on
the first env read (TERM), which then hung because the parent CLI holds stdin
in raw mode and the prompt could not be answered.

Restore Node.js semantics in the pass-through path: when the subcommand
executes user code (run/test/bench/serve) and no explicit permission flag is
present, inject -A. Callers that pass their own permission flags (vitest
workers spawn "run -A ...") are left untouched. Permission-flag detection
covers long, short, bundled and =value forms, mirroring the CLI parser.
Comment thread libs/node_shim/lib.rs
Comment on lines +3274 to +3299
const PERMISSION_LONG_FLAGS: &[&str] = &[
"allow-all",
"allow-read",
"allow-write",
"allow-net",
"allow-env",
"allow-run",
"allow-sys",
"allow-ffi",
"allow-import",
"deny-read",
"deny-write",
"deny-net",
"deny-env",
"deny-run",
"deny-sys",
"deny-ffi",
"deny-import",
"permission-set",
];

/// Short-form permission flag characters. Mirrors the `.short(...)` aliases in
/// the CLI parser: -A/-R/-W/-N/-E/-S/-I plus -P for `--permission-set`.
const PERMISSION_SHORT_FLAGS: &[char] =
&['A', 'R', 'W', 'N', 'E', 'S', 'I', 'P'];

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not great, but once I move CLI parsing to libs/cli_parser/ fully it will get much better

@bartlomieju
bartlomieju merged commit a72c413 into main Jun 23, 2026
136 checks passed
@bartlomieju
bartlomieju deleted the fix/forward-perms-deno-subcommand-spawn branch June 23, 2026 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tanstack-start init cli asks for granted permissions

1 participant