Repository navigation
Conversation
LUOSENGWA
requested a deployment
to
ai-review-approved
October 4, 2026 21:18 — with
GitHub Actions
Waiting
|
Hi @LUOSENGWA, this is your 8th Pull Request. 📋 About PR TemplateTo help maintainers review your PR faster, please make sure to include:
Complete PR information helps speed up the review process. You can edit the PR description to add these details. 🙌 Join Developer CommunityThanks so much for your contribution! We'd love to invite you to join the official QwenPaw developer group! You can find the Discord and DingTalk group links under the "Developer Community" section on our docs page: We truly appreciate your enthusiasm—and look forward to your future contributions! 😊 We'll review your PR soon. |
React.lazy caches the promise it is given, so a rejected dynamic import is re-thrown on every re-render and the existing state-keyed retry could never succeed, leaving chunk-load failures unrecoverable without a full page reload (agentscope-ai#7815). Route all lazy imports through the existing lazyWithRetry helper and cover the retry-budget exhaustion path with a test.
LUOSENGWA
force-pushed
the
fix/console-lazy-retry
branch
from
October 4, 2026 21:58
70d2032 to
4a67f2b
Compare
LUOSENGWA
requested a deployment
to
ai-review-approved
October 4, 2026 21:58 — with
GitHub Actions
Waiting
5 of 19 tasks
This branch is waiting to be deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

fix(console): let lazy-route loading actually retry after a chunk failure
Fixes #7815
Description
When a lazily-imported Console page fails to load (deploy race, stale hashed asset, transient network), the app is stuck on the failure screen — every subsequent navigation keeps showing it, and the only recovery is a full page reload.
There is a retry mechanism (state-keyed re-render), but it can never succeed, and the error boundary's reset path cannot break the deadlock. This PR makes the retry real.
Root cause
Lazy route components are created once, at module scope:
while retries are driven by component state (
retryKey), i.e. by re-rendering.React.lazycaches the promise it was given, including a rejected one. So:lazy()instance re-throws the same cached rejection immediately;window.location.reload()(which resets the module registry) escapes.The same applies to the boundary's
resetKeypath: it clears the error state, but the underlying lazy wrapper is still poisoned.Change
Add a small retry-aware lazy helper and route lazy imports through it:
Behaviour:
ChunkErrorBoundaryUI (Reload / restart runtime) is unchanged.Existing
Suspensefallbacks andChunkErrorBoundaryare untouched; only the lazy factory changes.Tests
New unit tests for the helper (mocking a dynamic import that fails once and then succeeds):
Plus a boundary-level test: with a flaky import, retry leads back to the page instead of a permanent failure state.
Verification
npm test(console) — new tests pass; existingChunkErrorBoundarytests unchanged.问题:控制台懒加载页面加载失败后不可恢复——后续每次切页都停在失败画面,只能整页刷新。(#7815)
根因(源码级):懒加载组件在模块级只创建一次(
const DesktopOSPage = lazy(() => import("./os/DesktopOS"))),而重试靠 state 重渲染(retryKey)。React.lazy会缓存被拒绝的 promise:重渲染时立刻重新抛出同一个错误,不会发起新的 import → 重试永远不可能成功;错误边界resetKey只清了错误态,底层的 lazy 包装依旧是"中毒"状态。唯一出路是window.location.reload()(重置模块注册表)。改动:新增
lazyWithRetry小工具并让懒加载走它——失败时清掉缓存(下次渲染真的发起新的动态 import)、失败后自动重试一次(对瞬时抖动/发布竞态有效,用带 cache-busting 的 URL 避免再次命中陈旧 chunk);两次都失败则原样抛给既有ChunkErrorBoundary(Reload / 重启 runtime 的 UI 不变)。Suspense与边界组件零改动,只替换 lazy 工厂。测试:新增工具单测——①首次失败、第二次成功(修复前必失败,因为缓存拒绝会被重抛);②两次都失败 → 错误照常交给边界;③成功路径只 import 一次;另加边界级用例:抖动导入后重试能回到页面,而不是永久失败态。
验证:控制台
npm test全绿(新用例通过、既有边界用例不变);手动——用 devtools 屏蔽某懒加载路由的 chunk → 进入该路由 → 解除屏蔽并重试 → 页面无需整页刷新即可加载(修复前永远不行)。Evidence
1. Targeted test run (the retry path this PR targets) — transcript
2. All lazy route imports now go through the retry helper
3. Change scope
4. Manual reproduction (what to look for)
React.lazyinstance re-threw the cached rejection forever, so onlywindow.location.reload()recovered).