A failed background reload replaces the committed successful match with an error match
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 54/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- playwright, typescript, vite
- 领域
- frontend, testing-qa, web-dev
调研方向
从 load-client 中的 runBackground()、install() 和 publishMatches() 开始,追踪失败的后台加载器如何变得可见。使用 pnpm install && pnpm dev 运行链接的复现程序,并比较文档中的 match 快照。完成的标准是:后台重新加载失败时,之前已提交的页面和成功的 match 仍保持可见,而不会被错误组件替换。
由索引模型根据 Issue 内容生成。
描述
Which project does this relate to? Router
Describe the bug
A failed background refresh replaces a working page with an error page.
A route loads successfully and displays its content. Later, the router re-runs its loader in the background to refresh stale data. If that loader throws, the router changes the match’s status to 'error' and replaces the page with its errorComponent.
The previous loaderData is still available on the match. The router could keep showing the existing content, but instead the user loses the page they were viewing because a background refresh failed.
I’d expect the existing page to stay visible, with the app deciding whether to notify the user or offer a retry. Replacing it with an error page seems appropriate when the initial load fails, but looks like a bug when a background refresh fails.
Possible cause
In load-client, runBackground() appears to handle a loader error through the same install() path used for a blocking load. It then calls publishMatches(router, projected[1]), making the error state visible and replacing the page.
That publish step is skipped if another transaction has superseded the refresh, or for control outcomes such as redirects and cancellation. There doesn’t appear to be a separate check for a failed background loader that would preserve the successfully loaded page.
Complete minimal reproducer
https://github.com/TylerRick/tanstack-router-background-reload-error-repro
Steps to Reproduce the Bug
pnpm install && pnpm dev, openhttp://localhost:5596— the page rendersPAGE: FIRSTfrom a successful loader.- Press fail the next load, then router.invalidate() (background). It sets a flag that makes the loader throw a plain
Error, then callsrouter.invalidate()with nosync. The router hasdefaultStaleReloadMode: 'background'anddefaultStaleTime: 0. - The harness waits for the loader to re-run and for fetching to stop (no sleeps), then prints the match snapshot before and after, plus the rendered heading:
before: {"routeId":"/","status":"success","invalid":false,"hasLoaderData":true,"isFetching":false}
after: {"routeId":"/","status":"error","invalid":true,"hasLoaderData":true,"isFetching":false,"error":"loader failed"}
rendered: ERROR COMPONENT: loader failed
Expected behavior
A failed background reload leaves the previously committed successful match and its rendered page in place, rather than replacing them with the error match. What the resulting invalidation and retry state should be is yours to decide.
Platform
- Router / Start Version — the same result on each of these three:
@tanstack/solid-router2.0.0-rc.4 /@tanstack/router-core1.171.22@tanstack/solid-router2.0.0-rc.5 /@tanstack/router-core1.171.22@tanstack/solid-router2.0.0-rc.5 /@tanstack/router-core1.171.27, via a pnpm override — rc.5 depends on 1.171.22, so the newest router-core has to be forced@tanstack/solid-router 2.0.0-rc.7 / @tanstack/router-core 1.171.22
- OS: Linux
- Browser: Chromium (Playwright 1.62.1)
- Browser Version: 151.0.0.0
- Bundler: Vite
- Bundler Version: 8.2.2
Additional context
Found in a TanStack Start app that re-runs its loaders from the client on every SSE reconnect, cross-tab message and visibility resume. One lost request during such a refresh replaced a working page with the app-wide error page until a later pass succeeded. The reproducer is deliberately client-only — no Start, no SSR, no server functions, no query client — because a plain loader rejection reaches the same path; an integration reproducer is easy to add if you would like one.
- 主要语言
- TypeScript
- 星标
- 15.3k
- 派生
- 1.9k
- 平均合并
- 1 天 5 小时
- 30 天内合并 PR
- 46
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TanStack/router 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
Masked navigation drops the first character of the hash each time (__tempLocation hash missing '#')可能已有人在做 @hassanabrar202 于 8 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
router-generator: lazy-load Prettier (costs ~300–450ms per build even when formatting is off)可能已有人在做 @Sheraff 于 27 天前认领。 未关闭package: router-generator performance
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
router-generator: sibling `physical()` subtrees in a virtual route config generate duplicate identifiers可能已有人在做 @Sheraff 于 27 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
docs(router): clarify static title fallback in SPA mode可能已有人在做 @Rohan-Dedhia 于 17 天前认领。 未关闭
难度 1/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
相似的 Issue
-
[BUG]: Shared links drop the configured basePath on GitHub Pages可能已有人在做 @anshulchikhale30-p 今天认领。 未关闭bug
难度 1/5 1 小时以内 新手友好度 88/100
StabilityNexus/IdentityTokens-EVM-Frontend#182 · 1 条评论 ·
维护者通常 1 天内回复
-
Add: GTrekker未关闭check:passed streams:add
难度 1/5 1 小时以内 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
Koenkk/zigbee-herdsman-converters#13900 ·
维护者通常 1 天内回复
-
area: ui Bug Payload OSS
难度 1/5 1 小时以内 新手友好度 88/100
payloadcms/payload#19839 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 88/100
jeanibarz/knowledge-base-mcp-server#1291 ·
维护者通常 1 天内回复