EnxDev opened a new pull request, #45234:
URL: https://github.com/apache/superset/pull/45234
### SUMMARY
On a dashboard with an auto-refresh interval, every chart is replaced by the
"No results were returned for this query" empty state for as long as its
refresh query is in flight, then comes back when the response lands. With a
short interval and slow queries the dashboard spends a good part of its time
showing empty states.
Auto-refresh (#37459) suppresses the loading spinner so the chart can stay
on screen while it refreshes. `ChartRenderer` already lets the render through
in that case, but it only hands data to `SuperChart` when the chart status is
`success` or `rendered`. During the refresh the status is `loading`, so
`SuperChart` gets `queriesData={undefined}` with `enableNoResults` on, and
renders the no-results state.
This is a regression from #39459, which converted `ChartRenderer` to a
function component. The class version had a `shouldComponentUpdate` that
returned `false` while results weren't ready, so the previous frame simply
stayed up. The function component re-renders on the status change, so it has to
keep passing the data itself.
The fix keeps passing the previous response while an auto-refresh is in
flight. The chart reducer leaves `queriesResponse` untouched on
`CHART_UPDATE_STARTED`, so the response in the store is still the last good one
until the new one replaces it. The clone handed to plugins is still memoised on
the response identity, so nothing is re-cloned when the status flips to
`loading`.
Nothing changes outside an auto-refresh: a normal load or a manual refresh
still shows the spinner, and a finished query with no rows still shows the
no-results state.
Related to #34682, which asks for charts to stay visible during a refresh.
This restores that for auto-refresh. It doesn't add the spinner overlay for
manual refreshes discussed there, so it doesn't close that issue.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before, on a dashboard with a table chart and `refresh_frequency: 10`,
sampling the chart while the `/api/v1/chart/data` request was delayed by a few
seconds:
| Refresh state | Chart shows |
|---|---|
| loaded | the table |
| auto-refresh request in flight | "No results were returned for this query"
|
| response received | the table |
I reproduced the "before" in a running instance. The "after" is covered by
the new tests, which run the real `SuperChart`; I haven't run a build of this
branch in a browser.
### TESTING INSTRUCTIONS
```bash
cd superset-frontend
npm run test -- src/components/Chart/ChartRenderer.refresh.test.tsx
```
The new file doesn't mock `SuperChart`, because the bug is in what
`SuperChart` does with the data it's given. Two of the four tests fail on
master: the chart disappearing when a refresh starts, and a chart mounted in
the middle of a refresh.
Manually:
1. Open a dashboard and set a refresh interval of 10 seconds.
2. Slow the chart data requests (browser devtools network throttling works).
3. Watch a chart across a refresh. On master it turns into the no-results
state until the request returns. With this change it stays as it was and then
updates.
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in
[SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]