Skip to content

Commit 5a974c0

Browse files
authored
fix(flamegraph): Only dispatch checkpoint when finishing flamegraph i… (#104564)
…nteraction There seems to be some edge cases where the checkpoint action is dispatched mid interaction and can result in an infinite re-render. This ensures the checkpoint is only emitted when the interaction finishes.
1 parent ccb61aa commit 5a974c0

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

static/app/components/profiling/flamegraph/interactions/useInteractionViewCheckPoint.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@ export function useInteractionViewCheckPoint({
2828
return;
2929
}
3030

31-
if (
32-
beforeInteractionConfigView.current &&
33-
!beforeInteractionConfigView.current.equals(view.configView)
34-
) {
35-
dispatch({type: 'checkpoint', payload: view.configView.clone()});
31+
// Check if we are finish the current interaction
32+
if (previousInteraction && lastInteraction === null) {
33+
if (
34+
beforeInteractionConfigView.current &&
35+
!beforeInteractionConfigView.current.equals(view.configView)
36+
) {
37+
dispatch({type: 'checkpoint', payload: view.configView.clone()});
38+
}
3639
}
3740
}, [dispatch, lastInteraction, previousInteraction, view]);
3841
}

0 commit comments

Comments
 (0)