Fixed an edge case profiling bug where the number of commits was wrong
Brian Vaughn committed
Apr 13, 2019 at 18:29 UTC
b76372c93dcfb3646e8b231fccce4cb763c54db3
1 file changed
+14
-13
src/devtools/store.js
+14
-13
@@ -410,24 +410,19 @@ export default class Store extends EventEmitter {
410
startProfiling(): void {
411
this._bridge.send('startProfiling');
412
413
- // Invalidate suspense cache if profiling data is being (re-)recorded.
414
- // Note that we clear now because any existing data is "stale".
415
- this._profilingCache.invalidate();
416
-
417
- this._isProfiling = false;
418
- this.emit('isProfiling');
413
+ // Don't actually update the local profiling boolean yet!
414
+ // Wait for onProfilingStatus() to confirm the status has changed.
415
+ // This ensures the frontend and backend are in sync wrt which commits were profiled.
416
+ // We do this to avoid mismatches on e.g. CommitTreeBuilder that would cause errors.
417
}
418
419
stopProfiling(): void {
420
this._bridge.send('stopProfiling');
421
424
- // Invalidate suspense cache if profiling data is being (re-)recorded.
425
- // Note that we clear again, in case any views read from the cache while profiling.
426
- // (That would have resolved a now-stale value without any profiling data.)
427
- this._profilingCache.invalidate();
428
-
429
- this._isProfiling = false;
430
- this.emit('isProfiling');
422
+ // Don't actually update the local profiling boolean yet!
423
+ // Wait for onProfilingStatus() to confirm the status has changed.
424
+ // This ensures the frontend and backend are in sync wrt which commits were profiled.
425
+ // We do this to avoid mismatches on e.g. CommitTreeBuilder that would cause errors.
426
}
427
428
toggleIsCollapsed(id: number, isCollapsed: boolean): void {
@@ -812,6 +807,12 @@ export default class Store extends EventEmitter {
807
808
if (this._isProfiling !== isProfiling) {
809
this._isProfiling = isProfiling;
810
+
811
+ // Invalidate suspense cache if profiling data is being (re-)recorded.
812
+ // Note that we clear again, in case any views read from the cache while profiling.
813
+ // (That would have resolved a now-stale value without any profiling data.)
814
+ this._profilingCache.invalidate();
815
+
816
this.emit('isProfiling');
817
}
818
};