saulojb commented on issue #37584:
URL: https://github.com/apache/superset/issues/37584#issuecomment-3841567004
Solved !!!
## Summary
Updates to avoid timeouts and an infinite refresh loop: added a staggered
interval to forced dashboard refreshes and fixed a Tab effect that retriggered
refreshes.
## Files changed
- index.jsx
- Tab.jsx
## What I changed
- index.jsx
- Added `staggerInterval` (from `dashboardInfo.metadata.stagger_time`,
falling back to 5000ms).
- Logged `interval: staggerInterval`.
- Call `onRefresh(chartIds, true, staggerInterval, dashboardInfo.id)` so
forced refreshes are staggered instead of all firing at once.
- Tab.jsx
- Removed `lastRefreshTime` from the `useEffect` dependency list that
triggers refresh when a tab becomes visible.
- Added a comment and an `eslint-disable-next-line
react-hooks/exhaustive-deps` to prevent re-running the effect when
`lastRefreshTime` updates (this previously caused an infinite refresh loop).
## Why
- `force=true` without staggering triggers many cache-bypassing queries
simultaneously, increasing the chance of server timeouts/errors.
- The `Tab` effect reacted to `lastRefreshTime` updates and re-fired
`onRefresh`, creating a loop. Avoiding that dependency prevents re-triggering
while preserving the intended initial refresh behavior.
## How to reproduce / validate
1. Install & build:
```bash
cd /home/saulo/Documentos/superset/superset-frontend
npm ci
npm run build
```
2. Run in dev and test the UI:
```bash
npm run dev-server
```
3. On a dashboard:
- Open a tab with charts.
- Click “Force Refresh”.
- Validate:
- No infinite refresh loop.
- Chart fetches are staggered (not all simultaneous).
- Event log shows `interval` set to `stagger_time` or `5000`ms fallback.
## Suggested commit / PR
- Branch: `fix/force-refresh-stagger`
- Commit message:
```
feat(dashboard): stagger force refresh and prevent tab refresh loop
```
- PR title: `Stagger force refresh & fix refresh loop`
- PR body:
```
Adds a staggered interval to forced dashboard refreshes to reduce server
load and fixes an infinite refresh loop in the Tab component by removing
`lastRefreshTime` from the effect deps.
```
Compiled version -> assets.zip, replace in the superset/static/ folder
<!-- Failed to upload "assets.zip" -->
--
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]