Skip to content

Commit 540ef12

Browse files
authored
fix(insights): Prevent duplicate rows in footer of Slow Queries widget (#93453)
Closes [DAIN-630: Widget footers incorrectly render duplicate rows when changing filters](https://linear.app/getsentry/issue/DAIN-630/widget-footers-incorrectly-render-duplicate-rows-when-changing-filters). There were two errors: 1. The `enabled: ` check wasn't working correctly. `data` is _always_ an array, and `!!([])` evalues to `true` so the query was always enabled. This causes an extra query with no conditions to fire every time the filters change 2. The `key` of the items in the footer was not unique, since multiple spans of the same normalized description can come back between requests and between renders. Duplicate keys can cause duplicate items in the list in some cases (like this case) This PR fixes both those errors. This is a little tough to see locally since it's obscured by DAIN-629.
1 parent a52dd10 commit 540ef12

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

static/app/views/insights/common/components/widgets/overviewSlowQueriesChartWidget.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export default function OverviewSlowQueriesChartWidget(props: LoadableChartWidge
7070
yAxis: ['avg(span.duration)'],
7171
sort: {field: 'avg(span.duration)', kind: 'desc'},
7272
topN: 3,
73-
enabled: !!queriesRequest.data,
73+
enabled: queriesRequest.data.length > 0,
7474
},
7575
Referrer.QUERIES_CHART,
7676
props.pageFilters
@@ -119,7 +119,9 @@ export default function OverviewSlowQueriesChartWidget(props: LoadableChartWidge
119119
const footer = hasData && (
120120
<WidgetFooterTable>
121121
{queriesRequest.data?.map((item, index) => (
122-
<Fragment key={item['sentry.normalized_description']}>
122+
<Fragment
123+
key={`${item['project.id']}-${item['span.group']}-${item['sentry.normalized_description']}`}
124+
>
123125
<div>
124126
<SeriesColorIndicator
125127
style={{

0 commit comments

Comments
 (0)