🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Include retained ownership keys in explicit collection cleanup.
As flagged in a previous review, queryToRows retains ownership keys for queries removed from state.observers during retention. The cleanup() method still only iterates state.observers.keys(), leaving queryToRows and rowToQueries populated for retained queries when an explicit collection cleanup occurs.
Build the cleanup key set by combining state.observers and queryToRows to ensure retained queries are properly cleaned up.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/query-db-collection/src/query.ts` around lines 740 - 741, Update
cleanup() to build its query-key set from both state.observers.keys() and
queryToRows keys, then use that combined set when removing ownership data so
retained queries are fully cleared from queryToRows and rowToQueries during
explicit collection cleanup.
✅ Addressed in commit b9a204f