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
This commit is contained in:
arielbackenroth 2024-11-25 17:21:39 +00:00 committed by Jessica Janiuk
parent bae473d718
commit 118803035f

View file

@ -591,14 +591,21 @@ export class ApplicationRef {
if (!this.zonelessEnabled) {
this.dirtyFlags |= ApplicationRefDirtyFlags.ViewTreeGlobal;
}
// Run `_tick()` in the context of the most recent snapshot, if one exists.
this.tracingSnapshot?.run(TracingAction.CHANGE_DETECTION, this._tick) ?? this._tick();
this._tick();
}
/** @internal */
_tick = (): void => {
this.tracingSnapshot = null;
if (this.tracingSnapshot !== null) {
const snapshot = this.tracingSnapshot;
this.tracingSnapshot = null;
// Ensure we always run `_tick()` in the context of the most recent snapshot,
// if one exists. Snapshots may be reference counted by the implementation so
// we want to ensure that if we request a snapshot that we use it.
snapshot.run(TracingAction.CHANGE_DETECTION, this._tick);
return;
}
(typeof ngDevMode === 'undefined' || ngDevMode) && this.warnIfDestroyed();
if (this._runningTick) {