DbClient.cleanup() cleans up a live query's source before the live query, logging an error on every SSR request
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 65/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- react, typescript
- 領域
- database
研究方向
Start by locating DbClient.cleanup() and the live query cleanup registration it processes. Read the cleanup path alongside the source-cleaned error handling, then reproduce the issue using the supplied SSR example with chained useLiveQuery calls. Done means whole-client cleanup of those queries completes without logging the source-cleaned error.
由索引模型根據 Issue 內容生成。
描述
Problem
On the server, routerWithDbClient cleans up the request's DbClient once the render finishes. When one useLiveQuery reads from the collection another useLiveQuery returned (as in "Caching Intermediate Results"), every request logs:
[Live Query Error] Source collection 'live-query-2' was manually cleaned up while live query 'live-query-3' depends on it. Live queries prevent automatic GC, so this was likely a manual cleanup() call.
DbClient.cleanup() runs every registered live query cleanup at once, in creation order. The source query was created first, so it's cleaned up before the query that depends on it, and the dependent query reports an error. A single unchained live query cleans up silently.
Repro
@tanstack/db 0.15.1, @tanstack/react-db 0.5.11, React 19.3.1, Bun:
import { DbClient, DbProvider, collectionOptions, localOnlyCollectionOptions, useLiveQuery } from '@tanstack/react-db'
import { renderToString } from 'react-dom/server'
const todos = collectionOptions('todos', () =>
localOnlyCollectionOptions({ id: 'todos', getKey: (t: { id: number }) => t.id, initialData: [{ id: 1 }, { id: 2 }] }),
)
function Todos() {
const { collection: base } = useLiveQuery({ queryKey: ['base'], query: (q) => q.from({ todo: todos }) })
const { data } = useLiveQuery({ queryKey: ['page', base.id], query: (q) => q.from({ todo: base }) })
return <p>{data.length}</p>
}
const client = new DbClient()
client._setSsrServerCleanupEnabled(true) // what routerWithDbClient does on the server
renderToString(<DbProvider client={client}><Todos /></DbProvider>)
await client.cleanup() // logs the error above
Expected
A whole-client cleanup() tears the queries down without errors: either dependents before their sources, or no source-cleaned error for a query the same cleanup is about to clean up anyway.
- 主要語言
- TypeScript
- 星號
- 4k
- 分支
- 277
- 平均合併
- 1 天 7 小時
- 30 天內合併 PR
- 191
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
TanStack/db 的其他 Issue
-
難度 1/5 1-3 小時 新手友好度 88/100
維護者通常 1 天內回覆
-
OfflineExecutor.dispose() never settles pendingTransactionPromises可能已有人在做 @Claire-ovo 於 6 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
Two @tanstack/db tests time out under CPU load because a cold module import counts against the 5 s default timeout可能已有人在做 @jp-knj 於 4 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
Disabled useLiveQuery fails SSR hydration with error 253可能已有人在做 @Jaime02 於 1 天前認領。 未關閉
難度 4/5 3-5 天 新手友好度 42/100
維護者通常 1 天內回覆
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 66/100
Equal-Vote/bettervoting#1754 ·
維護者通常 2 天內回覆
-
難度 1/5 1 小時以內 新手友好度 82/100
Doist/todoist-sdk-typescript#740 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 62/100
privatenumber/cleye#47 ·
-
clawsweeper:fix-shape-clear clawsweeper:queueable-fix clawsweeper:source-repro impact:auth-provider issue-rating: 🦞 diamond lobster no-stale P1
難度 2/5 1-3 小時 新手友好度 70/100
steipete/oracle#614 · 1 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
enhancement
難度 2/5 1-3 小時 新手友好度 72/100
MoonshotAI/kimi-code#4591 ·
維護者通常 1 天內回覆