Skip to content

Commit 1faac2d

Browse files
authored
fix(ext/node): handle node child_process with --v8-options flag (#24804)
Makes `v8flags` package from NPM work.
1 parent f6fad68 commit 1faac2d

File tree

6 files changed

+34
-0
lines changed

6 files changed

+34
-0
lines changed

ext/node/polyfills/internal/child_process.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,7 @@ const kNodeFlagsMap = new Map([
10301030
["--v8-pool-size", kLongArg],
10311031
]);
10321032
const kDenoSubcommands = new Set([
1033+
"add",
10331034
"bench",
10341035
"bundle",
10351036
"cache",
@@ -1046,6 +1047,7 @@ const kDenoSubcommands = new Set([
10461047
"install",
10471048
"lint",
10481049
"lsp",
1050+
"publish",
10491051
"repl",
10501052
"run",
10511053
"tasks",
@@ -1092,6 +1094,12 @@ function toDenoArgs(args: string[]): string[] {
10921094
let isLongWithValue = false;
10931095
let flagValue;
10941096

1097+
if (flag === "--v8-options") {
1098+
// If --v8-options is passed, it should be replaced with --v8-flags="--help".
1099+
denoArgs.push("--v8-flags=--help");
1100+
continue;
1101+
}
1102+
10951103
if (flagInfo === undefined) {
10961104
// If the flag was not found, it's either not a known flag or it's a long
10971105
// flag containing an '='.

tests/registry/npm/v8flags/registry.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
4.17 KB
Binary file not shown.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"args": "run -A main.js",
3+
"output": "main.out",
4+
"exitCode": 0
5+
}

tests/specs/run/npm_v8flags/main.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import v8flags from "npm:[email protected]";
2+
3+
const flags = await new Promise((resolve, reject) => {
4+
v8flags((err, flags) => {
5+
if (err) {
6+
reject(err);
7+
} else {
8+
resolve(flags);
9+
}
10+
});
11+
});
12+
13+
if (flags.length < 100) {
14+
throw new Error("Expected at least 100 flags");
15+
}
16+
17+
console.log("ok");

tests/specs/run/npm_v8flags/main.out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Download http://localhost:4260/v8flags
2+
Download http://localhost:4260/v8flags/v8flags-4.0.1.tgz
3+
ok

0 commit comments

Comments
 (0)