Error: schema with key or id "BuilderProgressSchema" already exists #20847
Labels
area: @angular-devkit/core
freq1: low
Only reported by a handful of users who observe it rarely
severity5: regression
type: bug/fix
Milestone
🐞 Bug report
Command (mark with an
x
)Is this a regression?
Yes, this didn't cause issues when using angular 11.
Description
Any builder that ends up using multiple instances of
@angular-devkit/architect
results in an error.Example scenario: package 1 exposes a builder that executes a builder in package 2, both packages have their own copy of
@angular-devkit/architect
in node_modules, e.g. because of deviating versions or because the package manager doesn't hoist the dependency.🔬 Minimal Reproduction
Clone https://github.com/bgotink/ngx-playwright/tree/repro-angular-schema-error and try to build
The last command uses a builder from one package to run multiple builders from another package. Both of these packages have an identical copy of
@angular-devkit/architect
version0.1200.0-rc.2
while thenode_modules
folder itself contains@angular-devkit/architect
version0.1200.0
.Building works fine if the situation is identical but using angular 11 packages.
Building also works fine if I add a resolution to force only a single (hoisted) version of
@angular-devkit/architect
to be installed.🔥 Exception or Error
I've logged the ids of compiled schemas before and after compilation and noticed that two copies of the
BuilderProgressSchema
schema are being compiled at the same time.This didn't give rise to issues in angular 11 because the
CoreSchemaRegistry
first tried to compile the schemas synchronously, which works for these schemas. In angular 12, the compilation is always asynchronous, which means multiple schemas can end up being compiled at the same time. This breaks as ajv only supports compiling one schema any given id. The relevant part ofCoreSchemaRegistry#_compile
function boils down towhich ends up removing the schema twice and then compiling it twice, causing the error above.
🌍 Your Environment
Anything else relevant?
The text was updated successfully, but these errors were encountered: