Skip to content

Commit 2bffacb

Browse files
JeanMechemmalerba
authored andcommitted
refactor(core): throw an Cyclic Dependency Error in prod mode (#60118)
Prior to this change, cyclic injection didn't trigger any error in prod mode, resulting into injecting the `CIRCULAR` object. This could lead to strange errors where no method would be found on the token. fixes #60074 PR Close #60118
1 parent f24a8c6 commit 2bffacb

File tree

12 files changed

+12
-1
lines changed

12 files changed

+12
-1
lines changed

packages/core/src/di/r3_injector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ export class R3Injector extends EnvironmentInjector {
469469
private hydrate<T>(token: ProviderToken<T>, record: Record<T>): T {
470470
const prevConsumer = setActiveConsumer(null);
471471
try {
472-
if (ngDevMode && record.value === CIRCULAR) {
472+
if (record.value === CIRCULAR) {
473473
throwCyclicDependencyError(stringify(token));
474474
} else if (record.value === NOT_YET) {
475475
record.value = CIRCULAR;

packages/core/test/bundling/animations-standalone/bundle.golden_symbols.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@
477477
"stringify",
478478
"stringifyCSSSelector",
479479
"style",
480+
"throwCyclicDependencyError",
480481
"throwProviderNotFoundError",
481482
"timeoutProvider",
482483
"transition",

packages/core/test/bundling/animations/bundle.golden_symbols.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@
503503
"stringify",
504504
"stringifyCSSSelector",
505505
"style",
506+
"throwCyclicDependencyError",
506507
"throwProviderNotFoundError",
507508
"timeoutProvider",
508509
"transition",

packages/core/test/bundling/cyclic_import/bundle.golden_symbols.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@
409409
"storeLViewOnDestroy",
410410
"stringify",
411411
"stringifyCSSSelector",
412+
"throwCyclicDependencyError",
412413
"throwProviderNotFoundError",
413414
"timeoutProvider",
414415
"uniqueIdCounter",

packages/core/test/bundling/defer/bundle.golden_symbols.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,7 @@
879879
"storeLViewOnDestroy",
880880
"stringify",
881881
"stringifyCSSSelector",
882+
"throwCyclicDependencyError",
882883
"throwProviderNotFoundError",
883884
"timeoutProvider",
884885
"trackMovedView",

packages/core/test/bundling/forms_reactive/bundle.golden_symbols.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@
613613
"storeLViewOnDestroy",
614614
"stringify",
615615
"stringifyCSSSelector",
616+
"throwCyclicDependencyError",
616617
"throwInvalidWriteToSignalError",
617618
"throwInvalidWriteToSignalErrorFn",
618619
"throwProviderNotFoundError",

packages/core/test/bundling/forms_template_driven/bundle.golden_symbols.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,7 @@
606606
"storeLViewOnDestroy",
607607
"stringify",
608608
"stringifyCSSSelector",
609+
"throwCyclicDependencyError",
609610
"throwInvalidWriteToSignalError",
610611
"throwInvalidWriteToSignalErrorFn",
611612
"throwProviderNotFoundError",

packages/core/test/bundling/hello_world/bundle.golden_symbols.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@
329329
"storeLViewOnDestroy",
330330
"stringify",
331331
"stringifyCSSSelector",
332+
"throwCyclicDependencyError",
332333
"throwProviderNotFoundError",
333334
"timeoutProvider",
334335
"uniqueIdCounter",

packages/core/test/bundling/hydration/bundle.golden_symbols.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@
441441
"stringify",
442442
"stringifyCSSSelector",
443443
"subscribeOn",
444+
"throwCyclicDependencyError",
444445
"throwProviderNotFoundError",
445446
"timeoutProvider",
446447
"transferCacheInterceptorFn",

packages/core/test/bundling/router/bundle.golden_symbols.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,7 @@
703703
"take",
704704
"takeLast",
705705
"tap",
706+
"throwCyclicDependencyError",
706707
"throwError2",
707708
"throwIfEmpty",
708709
"throwInvalidWriteToSignalErrorFn",

0 commit comments

Comments
 (0)