Angular · Senior · Question 56 of 75
How do you make SSR wait for async work that isn't an HTTP request (e.g. a timer-based init)?
const pending = inject(PendingTasks);
pending.run(() => loadWidgetConfig());- ✓Correct answer: Register it with
PendingTasks, so the app isn't considered stable until it finishes - 2Use
setTimeoutwith a long delay - 3SSR always waits for all promises
Explanation
SSR serializes the page once the app is stable. Without zone.js, Angular can't see arbitrary promises, so long-lived work must be tracked explicitly.