Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
jackofdiamond5 opened this issue Nov 20, 2024 · 2 comments
Open
1 task done
Labels
area: @angular/build freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix

Comments

@jackofdiamond5
Copy link

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

@alan-agius4 alan-agius4 added type: bug/fix freq1: low Only reported by a handful of users who observe it rarely severity5: regression area: @angular/build labels Nov 20, 2024
@clydin
Copy link
Member

clydin commented Nov 20, 2024

Thank you for the report. This is something the team will be investigating.

For max-old-space-size specifically, you may not need to use that option anymore with the Angular CLI. Newer Node.js versions have improved their memory initialization process significantly over previous versions.

@jackofdiamond5
Copy link
Author

jackofdiamond5 commented Nov 20, 2024

For max-old-space-size specifically, you may not need to use that option anymore with the Angular CLI. Newer Node.js versions have improved their memory initialization process significantly over previous versions.

@clydin Yeah you're right, I don't need the max-old-space-size anymore, I used it as a mere example to illustrate a V8 option that would cause an error when used like that.

One exception is with ng lint where we have a huge application and currently, in order to lint it, we use that flag, otherwise it runs out of memory. But without going through the code I'm going to guess that the ng lint does not spawn any workers and that's why it doesn't throw like ng serve/build do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: @angular/build freq1: low Only reported by a handful of users who observe it rarely severity5: regression type: bug/fix
Projects
None yet
Development

No branches or pull requests

3 participants