Repository navigation
fix(ext/node): forward permissions when spawning deno with subcommand args - #35443
Merged
Merged
Conversation
… 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.
bartlomieju
commented
Jun 23, 2026
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']; | ||
|
|
Member
Author
There was a problem hiding this comment.
Not great, but once I move CLI parsing to libs/cli_parser/ fully it will get much better
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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