Skip to content

Passing in V8 flags to a node process that executes ng build/serve throws #28901

Closed
@jackofdiamond5

Description

@jackofdiamond5

Command

build

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

18.2.12

Description

I am firing a nodejs process that executes the ng build schematic.
For example, it looks something like this - node --max-old-space-size=4096 node_modules/@angular/cli/bin/ng build. This throws because of the --max-old-space-size V8 flag that I pass in to node.

I traced the problem to this PR#28758 which uses process.execArgv and passes them in as execArgv to the options of the newly-created worker. Later on piscina will spawn a worker with the provided options, without doing any filtering, but I figured this is the intended behavior on their part.

According to nodejs when spawning worker threads, we cannot pass in any V8 flags (ref). Also, there's an open issue nodejs/node#41103 to make worker threads stop throwing errors for unsupported options but until that is resolved my best guess is that if process.execArgv is to be used, then some sort of filtering should be applied on these options before passing them in to the worker's constructor.

Minimal Reproduction

1, Create a new application with @angular/cli@19.
2. Navigate to the newly-created project's root.
3. Run node --max-old-space-size=4096 node_modules/@angular/cli/bin/ng build

Exception or Error

✘ [ERROR] Initiated Worker with invalid execArgv flags: --max-old-space-size=4096 [plugin angular-compiler]
 node_modules/piscina/dist/index.js:130:23:
      130 │         const worker = new node_worker_threads_1.Worker((0, node_...

Your Environment

Angular CLI: 19.0.0
Node: 20.17.0
Package Manager: npm 10.8.2
OS: win32 x64

Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1900.0 (cli-only)
@angular-devkit/core         19.0.0 (cli-only)
@angular-devkit/schematics   19.0.0 (cli-only)
@schematics/angular          19.0.0 (cli-only)

Anything else relevant?

No response

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions