From b76372c93dcfb3646e8b231fccce4cb763c54db3 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Sat, 13 Apr 2019 18:29:39 -0700 Subject: [PATCH] Fixed an edge case profiling bug where the number of commits was wrong --- src/devtools/store.js | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/devtools/store.js b/src/devtools/store.js index 38d33f2a6a..63d87f2544 100644 --- a/src/devtools/store.js +++ b/src/devtools/store.js @@ -410,24 +410,19 @@ export default class Store extends EventEmitter { startProfiling(): void { this._bridge.send('startProfiling'); - // Invalidate suspense cache if profiling data is being (re-)recorded. - // Note that we clear now because any existing data is "stale". - this._profilingCache.invalidate(); - - this._isProfiling = false; - this.emit('isProfiling'); + // Don't actually update the local profiling boolean yet! + // Wait for onProfilingStatus() to confirm the status has changed. + // This ensures the frontend and backend are in sync wrt which commits were profiled. + // We do this to avoid mismatches on e.g. CommitTreeBuilder that would cause errors. } stopProfiling(): void { this._bridge.send('stopProfiling'); - // Invalidate suspense cache if profiling data is being (re-)recorded. - // Note that we clear again, in case any views read from the cache while profiling. - // (That would have resolved a now-stale value without any profiling data.) - this._profilingCache.invalidate(); - - this._isProfiling = false; - this.emit('isProfiling'); + // Don't actually update the local profiling boolean yet! + // Wait for onProfilingStatus() to confirm the status has changed. + // This ensures the frontend and backend are in sync wrt which commits were profiled. + // We do this to avoid mismatches on e.g. CommitTreeBuilder that would cause errors. } toggleIsCollapsed(id: number, isCollapsed: boolean): void { @@ -812,6 +807,12 @@ export default class Store extends EventEmitter { if (this._isProfiling !== isProfiling) { this._isProfiling = isProfiling; + + // Invalidate suspense cache if profiling data is being (re-)recorded. + // Note that we clear again, in case any views read from the cache while profiling. + // (That would have resolved a now-stale value without any profiling data.) + this._profilingCache.invalidate(); + this.emit('isProfiling'); } };