Skip to content

Commit 47e1580

Browse files
authored
fix(profiling): Maximum update depth exceeded error on flamegraphs (#104544)
Not sure why but when clicking around the flamegraphs, sometimes, `location.query` updates a lot and this causes the options menu to hit a maximum update depth exceeded error. Instead of depending on `location.query`, depend on the values, which are strings, directly so there are fewer updates. Fixes JAVASCRIPT-34VQ
1 parent 46c3eb2 commit 47e1580

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

static/app/components/profiling/flamegraph/flamegraphToolbar/flamegraphOptionsMenu.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ function FlamegraphOptionsMenu({
4646
});
4747
}, [canvasPoolManager, organization, profileType]);
4848

49-
const continuousLocationDescriptor: {end: string; start: string} | null =
50-
useMemo(() => {
49+
const continuousLocationDescriptor: {end: string; start: string} | null = useMemo(
50+
() => {
5151
if (
5252
typeof location.query.start !== 'string' ||
5353
typeof location.query.end !== 'string' ||
@@ -60,7 +60,16 @@ function FlamegraphOptionsMenu({
6060
start: new Date(location.query.start).toISOString(),
6161
end: new Date(location.query.end).toISOString(),
6262
};
63-
}, [location.query]);
63+
},
64+
// DO NOT CHANGE THE DEPENDENCY LIST TO `[location.query]`
65+
//
66+
// Not 100% sure what's causing it yet but when interacting with the flamegraph,
67+
// sometimes, the `location.query` reference changes non stop causing an
68+
// Maximum update depth exceeded error.
69+
//
70+
// By depenending on the individual values, which are strings, this becomes stable.
71+
[location.query.profilerId, location.query.start, location.query.end]
72+
);
6473

6574
return (
6675
<Fragment>

0 commit comments

Comments
 (0)