Skip to content

Commit 4aeec9f

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 b4feeb5 commit 4aeec9f

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
@@ -473,7 +473,7 @@ export class R3Injector extends EnvironmentInjector {
473473
private hydrate<T>(token: ProviderToken<T>, record: Record<T>): T {
474474
const prevConsumer = setActiveConsumer(null);
475475
try {
476-
if (ngDevMode && record.value === CIRCULAR) {
476+
if (record.value === CIRCULAR) {
477477
throwCyclicDependencyError(stringify(token));
478478
} else if (record.value === NOT_YET) {
479479
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
@@ -478,6 +478,7 @@
478478
"stringify",
479479
"stringifyCSSSelector",
480480
"style",
481+
"throwCyclicDependencyError",
481482
"throwProviderNotFoundError",
482483
"timeoutProvider",
483484
"transition",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@
504504
"stringify",
505505
"stringifyCSSSelector",
506506
"style",
507+
"throwCyclicDependencyError",
507508
"throwProviderNotFoundError",
508509
"timeoutProvider",
509510
"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
@@ -410,6 +410,7 @@
410410
"storeLViewOnDestroy",
411411
"stringify",
412412
"stringifyCSSSelector",
413+
"throwCyclicDependencyError",
413414
"throwProviderNotFoundError",
414415
"timeoutProvider",
415416
"uniqueIdCounter",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,7 @@
881881
"storeLViewOnDestroy",
882882
"stringify",
883883
"stringifyCSSSelector",
884+
"throwCyclicDependencyError",
884885
"throwProviderNotFoundError",
885886
"timeoutProvider",
886887
"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
@@ -332,6 +332,7 @@
332332
"storeLViewOnDestroy",
333333
"stringify",
334334
"stringifyCSSSelector",
335+
"throwCyclicDependencyError",
335336
"throwProviderNotFoundError",
336337
"timeoutProvider",
337338
"uniqueIdCounter",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@
442442
"stringify",
443443
"stringifyCSSSelector",
444444
"subscribeOn",
445+
"throwCyclicDependencyError",
445446
"throwProviderNotFoundError",
446447
"timeoutProvider",
447448
"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)