useLiveQuery({ query }) keeps a cleaned source after same-ID collection instance replacement
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 55/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- react, sqlite, typescript
Hướng nghiên cứu
Start with the useLiveQuery({ query }) migration path and the React test-renderer integration test using two same-ID persisted SQLite collections. Reproduce the replacement and cleanup sequence, then compare it with the explicit primitive queryKey case. Done means the replacement instance is followed without a stale value or cleanup error, or the migration warning/docs and tests clearly require the instance token.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Versions
@tanstack/react-db0.5.1@tanstack/db0.11.1@tanstack/expo-db-sqlite-persistence0.2.26
Problem
The recommended migration from useLiveQuery(query, [collection]) to useLiveQuery({ query }) loses collection instance identity. Structured IR identity uses collection.id. When a mounted hook is given a replacement collection with the same ID (for example, a newly initialized collection for the same account), the hook keeps its live query bound to the old instance.
We observed a stale value and, when the old instance is cleaned up, the exact runtime error:
[Live Query Error] Source collection 'wearable.settings.same-user' was manually cleaned up while live query 'live-query-1' depends on it.
Deterministic reproduction
- Create two local persisted collections with the same
id: 'wearable.settings.same-user', each over its own SQLite database. Put{ id: 'settings', automaticSync: false }in the first and{ id: 'settings', automaticSync: true }in the second. - Mount a component that calls
useLiveQuery({ query: q => q.from({ settings: currentCollection }) }). InitiallycurrentCollectionis the first collection; render and confirmfalse. - Set
currentCollectionto the second instance and rerender the mounted component without unmounting it. - The hook still returns
false. Clean up the first collection and the live-query error above appears.
We have a React test-renderer integration test with real persisted collections and SQLite. It fails this way without an explicit key and passes with queryKey: [instanceToken(currentCollection)], where instanceToken comes from a WeakMap assigning a primitive number per object instance. The old dependency-array form also tracked the instance.
Expected
A structured live query should follow a replaced collection instance even when its ID is reused. At minimum, the migration warning/docs should explain that an explicit primitive instance token is needed for this lifecycle; currently they suggest queryKey mainly for opaque queries or render performance. Passing the collection object directly in queryKey is not possible because stable hashing rejects non-plain objects.
- Ngôn ngữ chính
- TypeScript
- Star
- 3.9k
- Fork
- 268
- Merge trung bình
- 1 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 148
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của TanStack/db
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 50/100
TanStack/db#1992 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
TanStack/db#1972 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Effect-TS/effect#8728 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Add: CanalPlusSport8SK.skĐang mởcheck:passed streams:add
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
linagora/twake-drive-mobile#436 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] The shared instance selector's placeholder and no-match text ignore the display languageCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
apache/rocketmq-dashboard#5561 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 87/100
heygen-com/hyperframes#5002 ·
Maintainer thường phản hồi trong vòng 1 ngày