fix(dashboard): incorrect chart error with slow dataset api request (#18852)

* fix(dashboard): incorrect chart error with slow datasource api request

* update comments

* Add key to styled loading component
This commit is contained in:
Jesse Yang 2022-02-23 11:02:00 -08:00 committed by GitHub
parent 2c86d1a2b7
commit cdd4fa58d0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -208,6 +208,7 @@ class Chart extends React.PureComponent {
) {
return (
<Styles
key={chartId}
data-ui-anchor="chart"
className="chart-container"
data-test="chart-container"
@ -220,6 +221,7 @@ class Chart extends React.PureComponent {
return (
<ChartErrorMessage
key={chartId}
chartId={chartId}
error={error}
subtitle={message}

View File

@ -201,9 +201,10 @@ export default function chartReducer(
return Object.fromEntries(
Object.entries(charts).map(([chartId, chart]) => [
chartId,
// if render has failed, clear error message,
// which will trigger a re-render
chart.chartStatus === 'failed'
// some charts may not have properly handled missing datasource,
// causing a JS error, so we reset error message and try to re-render
// the chart once the datasource is fully loaded
chart.chartStatus === 'failed' && chart.chartStackTrace
? {
...chart,
chartStatus: '',