-
Notifications
You must be signed in to change notification settings - Fork 24.7k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
ngcc is non-deterministic #35180
Comments
Argh... 馃槦
Does running ngcc with the |
I was finding Now when trying with Seems like files across all packages + bundle types are randomly effected. Although in one case it was the Try running that script above... Currently I'm seeing the biggest changes between step 1+2 ( |
@gkalpak have you reproduced anything? After upgrading to v9.0.0 I'm consistently seeing the inconsistent variable names, but now none of the
|
@jbedard, I tried with the With |
Idk if I'd call that "expected"... I think running npm/yarn with the same lock file, cached or not, should produce the same result every single time. Is there any real reason other then sharing a single counter somewhere? Why not one per-file instead of global? Seems like that's what the |
If you added a postinstall script that changes
I imagine it wouldn't be super straight-forward (I might be wrong though), but it should be doable. |
Tracking at FW-2022 |
I just tried the reproduction given in #35180 (comment) and I cannot see any difference between the generated files. But I wonder if it is timing dependent and so I was just lucky? The versions of Angular etc I am testing with are:
@jbedard - could you take another look? |
I reproduced it running that script. @angular-0-init and @angular-2-rerun-fresh produced different results for quite a few files, only in the cdk and material though. My package package.json is:
|
I found the problem. These non-deterministic variables are generated by the Normally this is fine but for ngcc in async mode, we are creating multiple worker processes, each of which gets its own I think the solution is to recreate the |
Previously we had a singleton `ROOT_SCOPE` object, from which all `BindingScope`s derived. But this caused ngcc to produce non-deterministic output when running multiple workers in parallel, since each process had its own `ROOT_SCOPE`. In reality there is no need for `BindingScope` reference names to be unique across an entire application (or in the case of ngcc across all the libraries). Instead we just need uniqueness within a template. This commit changes the compiler to create a new root `BindingScope` each time it compiles a component's template. Resolves angular#35180
#36362) Previously we had a singleton `ROOT_SCOPE` object, from which all `BindingScope`s derived. But this caused ngcc to produce non-deterministic output when running multiple workers in parallel, since each process had its own `ROOT_SCOPE`. In reality there is no need for `BindingScope` reference names to be unique across an entire application (or in the case of ngcc across all the libraries). Instead we just need uniqueness within a template. This commit changes the compiler to create a new root `BindingScope` each time it compiles a component's template. Resolves #35180 PR Close #36362
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
馃悶 bug report
Affected Package
@angular/*
Is this a regression?
Not sure
Description
I'm finding
ngcc
is outputting non-deterministic results. Internally I've seen the ivy code swap variable names back and forth between runs, I haven't been able to reproduce this in isolation though. In other cases I'm seeing the exact same code, but with a single line of whitespace at the end which causes a different source-map hash. I've also seen the*.__ivy_ngcc_bak
files sometimes being left behind, this normally happens alongside the single line of whitespace.Non-deterministic results can break caching with tools like bazel. In the case of different variable names it could go a step further and produce different resulting .js files and bust browser caches etc.
Essentially has the same consequences as #34635 but seems less common.
馃敩 Minimal Reproduction
Running the following almost always produces different results between some of the
ngcc
runs.馃實 Your Environment
Angular Version:
9.0.0-rc.14, pretty sure it was also happening with 9.0.0-rc.10
The text was updated successfully, but these errors were encountered: