Skip to content

Commit

Permalink
fix(core): skip defer timers on the server (#55480)
Browse files Browse the repository at this point in the history
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 #55475.

PR Close #55480
  • Loading branch information
crisbeto authored and alxhub committed Apr 23, 2024
1 parent d5ee04e commit 8979fba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/core/src/defer/instructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,10 @@ export function renderDeferBlockState(

if (isValidStateChange(currentState, newState) &&
isValidStateChange(lDetails[NEXT_DEFER_BLOCK_STATE] ?? -1, newState)) {
const injector = hostLView[INJECTOR]!;
const tDetails = getTDeferBlockDetails(hostTView, tNode);
const needsScheduling = !skipTimerScheduling &&
// Skips scheduling on the server since it can delay the server response.
const needsScheduling = !skipTimerScheduling && isPlatformBrowser(injector) &&
(getLoadingBlockAfter(tDetails) !== null ||
getMinimumDurationForState(tDetails, DeferBlockState.Loading) !== null ||
getMinimumDurationForState(tDetails, DeferBlockState.Placeholder));
Expand Down
3 changes: 3 additions & 0 deletions packages/core/test/bundling/defer/bundle.golden_symbols.json
Original file line number Diff line number Diff line change
Expand Up @@ -2072,6 +2072,9 @@
{
"name": "isNodeMatchingSelectorList"
},
{
"name": "isPlatformBrowser"
},
{
"name": "isPlatformServer"
},
Expand Down

0 comments on commit 8979fba

Please sign in to comment.