Skip to content

Improve Defer Trigger Misconfiguration#67497

Open
SkyZeroZx wants to merge 2 commits intoangular:mainfrom
SkyZeroZx:refactor/improve-defer-diagnostic
Open

Improve Defer Trigger Misconfiguration#67497
SkyZeroZx wants to merge 2 commits intoangular:mainfrom
SkyZeroZx:refactor/improve-defer-diagnostic

Conversation

@SkyZeroZx
Copy link
Contributor

@SkyZeroZx SkyZeroZx commented Mar 6, 2026

On top #65553

Add two commits

Add diagnostics for idle prefetch triggers

Since adding support for @defer (on idle(500ms)), some idle + prefetch timing combinations are not detected correctly.

@defer (on idle(500ms); prefetch on idle(200ms) ) {
    <heavy-comp />
}

Currently, this throws an error that is actually incorrect

NG8021: Prefetch 'idle' matches the main trigger and provides no benefit. Remove the prefetch modifier.

Adds warning for prefetch without main defer trigger

Relative to #52746 and according examples in documentation

For example

@defer (prefetch when someFlag) {
  <heavy-comp />
}

This configuration may suggest that the prefetch will only run when someFlag becomes true.
However, since the main trigger still defaults to on idle, the deferred content can be fetched earlier during the browser’s idle period, effectively bypassing the intended condition.

Closes #52746

@pullapprove pullapprove bot requested a review from devversion March 6, 2026 19:26
@angular-robot angular-robot bot added detected: feature PR contains a feature commit area: compiler Issues related to `ngc`, Angular's template compiler labels Mar 6, 2026
@ngbot ngbot bot added this to the Backlog milestone Mar 6, 2026
@JeanMeche JeanMeche requested review from JeanMeche and removed request for devversion March 11, 2026 16:41
@pullapprove pullapprove bot requested a review from devversion March 11, 2026 16:41
@JeanMeche

This comment was marked as outdated.

@JeanMeche JeanMeche removed the request for review from devversion March 11, 2026 16:41
Extends the extended diagnostic for `@defer` trigger misconfiguration to include `on idle` triggers
Emit a warning when an `@defer` block uses `prefetch` triggers but does not define an explicit main trigger.

Closes angular#52746
@SkyZeroZx SkyZeroZx force-pushed the refactor/improve-defer-diagnostic branch from 46007c8 to e3e7aac Compare March 13, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: compiler Issues related to `ngc`, Angular's template compiler detected: feature PR contains a feature commit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Require main @defer triggers to be defined when prefetch conditions are present

2 participants