()
| 1646 | }) |
| 1647 | |
| 1648 | const cleanup = async () => { |
| 1649 | unsubscribeFromCollectionEvents() |
| 1650 | unsubscribeFromQueries() |
| 1651 | persistedRetentionTimers.forEach((timer) => { |
| 1652 | clearTimeout(timer) |
| 1653 | }) |
| 1654 | persistedRetentionTimers.clear() |
| 1655 | |
| 1656 | const allQueryKeys = [...hashToQueryKey.values()] |
| 1657 | const allHashedKeys = [...state.observers.keys()] |
| 1658 | |
| 1659 | // Force cleanup all queries (explicit cleanup path) |
| 1660 | // This ignores hasListeners and always cleans up |
| 1661 | for (const hashedKey of allHashedKeys) { |
| 1662 | forceCleanupQuery(hashedKey) |
| 1663 | } |
| 1664 | |
| 1665 | // Unsubscribe from cache events (cleanup already happened above) |
| 1666 | unsubscribeQueryCache() |
| 1667 | |
| 1668 | // Remove queries from TanStack Query cache |
| 1669 | await Promise.all( |
| 1670 | allQueryKeys.map(async (qKey) => { |
| 1671 | await queryClient.cancelQueries({ queryKey: qKey, exact: true }) |
| 1672 | queryClient.removeQueries({ queryKey: qKey, exact: true }) |
| 1673 | }), |
| 1674 | ) |
| 1675 | } |
| 1676 | |
| 1677 | /** |
| 1678 | * Unload a query subset - the subscription-based cleanup path (on-demand mode). |
nothing calls this directly
no test coverage detected