Skip to content

Commit 5948193

Browse files
crisbetoalxhub
authored andcommitted
fix(core): skip defer timers on the server (angular#55480)
Adds a check that disables the timer scheduling for `placeholder` and `loading` blocks on the server since the underlying timer will delay the server response. Fixes angular#55475. PR Close angular#55480
1 parent bcce85a commit 5948193

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

packages/core/src/defer/instructions.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,10 @@ export function renderDeferBlockState(
480480

481481
if (isValidStateChange(currentState, newState) &&
482482
isValidStateChange(lDetails[NEXT_DEFER_BLOCK_STATE] ?? -1, newState)) {
483+
const injector = hostLView[INJECTOR]!;
483484
const tDetails = getTDeferBlockDetails(hostTView, tNode);
484-
const needsScheduling = !skipTimerScheduling &&
485+
// Skips scheduling on the server since it can delay the server response.
486+
const needsScheduling = !skipTimerScheduling && isPlatformBrowser(injector) &&
485487
(getLoadingBlockAfter(tDetails) !== null ||
486488
getMinimumDurationForState(tDetails, DeferBlockState.Loading) !== null ||
487489
getMinimumDurationForState(tDetails, DeferBlockState.Placeholder));

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2096,6 +2096,9 @@
20962096
{
20972097
"name": "isNodeMatchingSelectorList"
20982098
},
2099+
{
2100+
"name": "isPlatformBrowser"
2101+
},
20992102
{
21002103
"name": "isPlatformServer"
21012104
},

0 commit comments

Comments
 (0)