Skip to content

Commit

Permalink
Log when a derived gets cleared (microsoft#236739)
Browse files Browse the repository at this point in the history
  • Loading branch information
hediet authored Dec 20, 2024
1 parent 094e96a commit 83c336d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/vs/base/common/observableInternal/derived.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ export class Derived<T, TChangeSummary = any> extends BaseObservable<T, void> im
*/
this.state = DerivedState.initial;
this.value = undefined;
getLogger()?.handleDerivedCleared(this);
for (const d of this.dependencies) {
d.removeObserver(this);
}
Expand Down
10 changes: 10 additions & 0 deletions src/vs/base/common/observableInternal/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export interface IObservableLogger {

handleDerivedCreated(observable: Derived<any>): void;
handleDerivedRecomputed(observable: Derived<any>, info: IChangeInformation): void;
handleDerivedCleared(observable: Derived<any>): void;

handleBeginTransaction(transaction: TransactionImpl): void;
handleEndTransaction(): void;
Expand Down Expand Up @@ -170,6 +171,15 @@ export class ConsoleObservableLogger implements IObservableLogger {
changedObservables.clear();
}

handleDerivedCleared(derived: Derived<unknown>): void {
if (!this._isIncluded(derived)) { return; }

console.log(...this.textToConsoleArgs([
formatKind('derived cleared'),
styled(derived.debugName, { color: 'BlueViolet' }),
]));
}

handleFromEventObservableTriggered(observable: FromEventObservable<any, any>, info: IChangeInformation): void {
if (!this._isIncluded(observable)) { return; }

Expand Down

0 comments on commit 83c336d

Please sign in to comment.