bikash-barnwal opened a new pull request, #43215:
URL: https://github.com/apache/superset/pull/43215

   ### SUMMARY
   
   `React.lazy` memoizes its factory's **rejection**, not just its resolution. 
Once the dynamic `import()` behind a route fails — a chunk that 404s after a 
redeploy, or a transient 502/503 from the asset server — the payload is 
permanently marked rejected. The component then throws `ChunkLoadError` 
forever: navigating away and back re-renders the same rejected payload, and 
only a full page reload clears it.
   
   Retrying *inside* the factory, before the promise handed to `React.lazy` 
settles, is the only way to recover, since nothing outside can reset that 
memoized state.
   
   This adds `lazyWithRetry`, a drop-in replacement that retries with 
exponential backoff (2 extra attempts, 500 ms doubling) and rejects with the 
last error once exhausted, and switches the lazily loaded routes and entry 
points to it: `views/routes.tsx`, `embedded/index.tsx`, 
`dashboard/containers/DashboardPage.tsx`, 
`dashboard/components/DashboardBuilder/DashboardBuilder.tsx`, 
`explore/components/ExploreViewContainer/index.tsx`.
   
   **What this does and doesn't fix**, since #41266 carries 
`validation:required` and the report doesn't say which case it hit: a 
*transient* failure now recovers on its own. A chunk that is permanently gone — 
an old hashed filename after a redeploy while the client still holds the 
previous index — still fails once the retries are exhausted, which is the 
correct outcome; recovering from that needs a reload-on-stale-manifest 
strategy, which is a larger change and not attempted here.
   
   The component constraint is lifted from `React.lazy`'s own signature 
(`Parameters<typeof lazy>[0]`) so call sites keep their prop types without this 
module spelling out an `any`.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   Before: one failed chunk request leaves the route permanently broken until 
the user reloads.
   After: the import is retried twice with backoff; a transient failure is 
invisible to the user.
   
   ### TESTING INSTRUCTIONS
   
   ```bash
   cd superset-frontend
   npm run test -- src/utils/lazyWithRetry.test.tsx
   npm run test -- src/views/routes src/dashboard/containers
   ```
   
   3 new tests: recovering from a transient `ChunkLoadError`, exhausting 
attempts and rethrowing the last error, and not retrying a successful import. 
16 tests across the affected route/container suites still pass. oxlint and 
oxfmt clean.
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: Fixes #41266
   - [ ] 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]

Reply via email to