Skip to content

Commit 431166d

Browse files
crisbetoAndrewKushnir
authored andcommitted
fix(core): skip component ID collision warning during SSR (#59625)
The component ID collision check tries to account for components being replaced by checking for the `type`, however that might not work during SSR. These changes disable the warning since it's primarily useful on the browser anyways. PR Close #59625
1 parent bc2ad7b commit 431166d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

packages/core/src/render3/definition.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,13 @@ function getComponentId<T>(componentDef: ComponentDef<T>): string {
750750

751751
const compId = 'c' + hash;
752752

753-
if (typeof ngDevMode === 'undefined' || ngDevMode) {
753+
if (
754+
(typeof ngDevMode === 'undefined' || ngDevMode) &&
755+
// Skip the check on the server since we can't guarantee the same component instance between
756+
// requests. Note that we can't use DI to check if we're on the server, because the component
757+
// hasn't been instantiated yet.
758+
(typeof ngServerMode === 'undefined' || !ngServerMode)
759+
) {
754760
if (GENERATED_COMP_IDS.has(compId)) {
755761
const previousCompDefType = GENERATED_COMP_IDS.get(compId)!;
756762
if (previousCompDefType !== componentDef.type) {

0 commit comments

Comments
 (0)