Skip to content

Commit 1188030

Browse files
arielbackenroththePunderWoman
authored andcommitted
fix(core): Ensure _tick is always run within the TracingSnapshot. (#58881)
Fix a bug where calls to _tick are called without running through the snapshot. This helps ensure that all snapshots that are requested are resumed. PR Close #58881
1 parent bae473d commit 1188030

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

packages/core/src/application/application_ref.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -591,14 +591,21 @@ export class ApplicationRef {
591591
if (!this.zonelessEnabled) {
592592
this.dirtyFlags |= ApplicationRefDirtyFlags.ViewTreeGlobal;
593593
}
594-
595-
// Run `_tick()` in the context of the most recent snapshot, if one exists.
596-
this.tracingSnapshot?.run(TracingAction.CHANGE_DETECTION, this._tick) ?? this._tick();
594+
this._tick();
597595
}
598596

599597
/** @internal */
600598
_tick = (): void => {
601-
this.tracingSnapshot = null;
599+
if (this.tracingSnapshot !== null) {
600+
const snapshot = this.tracingSnapshot;
601+
this.tracingSnapshot = null;
602+
603+
// Ensure we always run `_tick()` in the context of the most recent snapshot,
604+
// if one exists. Snapshots may be reference counted by the implementation so
605+
// we want to ensure that if we request a snapshot that we use it.
606+
snapshot.run(TracingAction.CHANGE_DETECTION, this._tick);
607+
return;
608+
}
602609

603610
(typeof ngDevMode === 'undefined' || ngDevMode) && this.warnIfDestroyed();
604611
if (this._runningTick) {

0 commit comments

Comments
 (0)