Skip to content

FIX solid-db, db: bug with solid not remounting with current data due to proxy issues#1608

Open
fezproof wants to merge 2 commits into
TanStack:refactor/live-query-observerfrom
fezproof:solid-remount-fix
Open

FIX solid-db, db: bug with solid not remounting with current data due to proxy issues#1608
fezproof wants to merge 2 commits into
TanStack:refactor/live-query-observerfrom
fezproof:solid-remount-fix

Conversation

@fezproof

@fezproof fezproof commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

🎯 Changes

Fixed a bug where cloning non enumerable properties causes solid to get stuck in an old state after mounting a query.
Tests have been added that check for the issue, and fail on the current upstream code.

This can be recreated in real life by using a keyed Show component that mounts a form, updating the data, then remounting the form. The data will show the correct value, but will revert when remounted. The data in the collection will be correct, but the ui will be out of sync.

✅ Checklist

  • I have tested this code locally with pnpm test.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a shared live query observer API that unifies live-query lifecycle handling across integrations.
  • Bug Fixes

    • Prevented cloning from capturing non-enumerable symbol metadata that could corrupt live updates.
    • Improved live query update behavior after component unmount/remount, including nested-field scenarios.
    • Corrected live-query lifecycle/notification edge cases (readiness/status transitions and stable snapshot behavior).
  • Tests

    • Added coverage for symbol cloning edge cases, remounting nested updates, and observer semantics across granular/wholesale modes.

@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR introduces a shared live-query observer with revision-aware snapshots and lifecycle dispatch, migrates Angular synchronization to it, adds conformance and lifecycle tests, and fixes cloning of non-enumerable symbol properties with Solid remount regression coverage.

Changes

Live-query observer platform

Layer / File(s) Summary
Observer contract and collection revisions
packages/db/src/live-query-observer.ts, packages/db/src/collection/..., packages/db/src/errors.ts, packages/db/src/index.ts
Adds the observer API, disabled snapshots, disposal error, collection state revisions, and package-root exports.
Observer lifecycle and dispatch
packages/db/src/live-query-observer.ts
Implements revision-aware snapshot caching, granular and wholesale subscriptions, status notifications, FIFO dispatch, preload, and disposal.
Observer lifecycle validation
packages/db/tests/live-query-observer.test.ts
Tests snapshot identity, subscription modes, readiness, status transitions, dispatch ordering, activation, disposal, and detached-state refresh.
Angular observer integration
packages/angular-db/src/index.ts, packages/angular-db/tests/...
Replaces Angular’s collection synchronization with a wholesale observer and updates mocks and conformance results for state revisions and status events.
Conformance coverage
packages/db/tests/conformance/...
Verifies keyed state shrinks with query recompilation and does not retain stale keys.
Enumerable symbol cloning fix
packages/db/src/proxy.ts, packages/db/tests/proxy.test.ts
Excludes non-enumerable symbol properties from deep clones while preserving enumerable symbols.
Solid remount regression coverage
packages/solid-db/tests/useLiveQuery.test.tsx
Verifies nested live-query values remain current after unmounting and remounting.
Release metadata
.changeset/live-query-observer.md, .changeset/loose-flies-sell.md
Records observer-related releases and the Solid cloning fix.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant FrameworkAdapter
  participant LiveQueryObserver
  participant Collection
  FrameworkAdapter->>LiveQueryObserver: subscribe()
  LiveQueryObserver->>Collection: attach change and status subscriptions
  Collection-->>LiveQueryObserver: publish change batch or status transition
  LiveQueryObserver-->>FrameworkAdapter: notify()
  FrameworkAdapter->>LiveQueryObserver: getSnapshot()
  LiveQueryObserver-->>FrameworkAdapter: cached state and data snapshot
Loading

Possibly related issues

Possibly related PRs

  • TanStack/db#1638 — Modifies the same Angular injectLiveQuery configuration and synchronization behavior.
  • TanStack/db#1641 — Also refactors Angular injectLiveQuery and shared live-query handling.
  • TanStack/db#1642 — Directly overlaps the shared observer export and Angular wholesale observer integration.

Suggested reviewers: kyleamathews

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is clearly related to the Solid remount bug fix and the db proxy change, even if a bit verbose.
Description check ✅ Passed The description follows the template with Changes, Checklist, and Release Impact sections and includes the key context.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/solid-db/tests/useLiveQuery.test.tsx (1)

2599-2704: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Extract duplicated remount test scaffolding into a helper.

Both tests repeat the same collection setup, updater, mount/unmount, and assertion flow. Pulling this into a focused helper will reduce drift and make future remount regressions easier to cover.

Refactor sketch
+function setupDeepNodeRemountTest(singleResult: boolean) {
+  const nodeId = 'node-1'
+  const collection = createCollection(
+    mockSyncCollectionOptions<DeepNode>({
+      id: singleResult ? 'remount-single-nested-test' : 'remount-array-nested-test',
+      getKey: (item) => item.id,
+      initialData: [{ id: nodeId, size: { min: 1, max: 10 } }],
+    }),
+  )
+  const updateMax = (max: number) => {
+    collection.update(nodeId, (draft) => {
+      draft.size.max = max
+    })
+  }
+  return { nodeId, collection, updateMax }
+}

As per coding guidelines, "Extract common logic into utility functions when identical or near-identical code blocks appear in multiple places" and "Prefer small, focused utility functions over large inline implementations."

🤖 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/solid-db/tests/useLiveQuery.test.tsx` around lines 2599 - 2704, Both
the 'single-row reflects the current value on remount' and 'array reflects the
current value on remount' tests contain nearly identical collection setup,
updateMax function, mount logic, and assertion patterns. Extract the common test
scaffolding into a reusable helper function that accepts a callback parameter to
handle the differences between the two tests (specifically how the query is
constructed with findOne versus without, and how the result is accessed). This
will eliminate the code duplication and make the tests more maintainable.

Source: Coding guidelines

🤖 Prompt for all review comments with 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.

Inline comments:
In @.changeset/loose-flies-sell.md:
- Line 6: The release note in the changeset file needs improved formatting for
clarity. Apply hyphenation to compound adjectives by adding hyphens to "non
enumerable" and "non current". Additionally, apply proper product casing to
"solid store" to match standard product naming conventions. These changes will
improve the readability and professionalism of the changelog entry.

---

Nitpick comments:
In `@packages/solid-db/tests/useLiveQuery.test.tsx`:
- Around line 2599-2704: Both the 'single-row reflects the current value on
remount' and 'array reflects the current value on remount' tests contain nearly
identical collection setup, updateMax function, mount logic, and assertion
patterns. Extract the common test scaffolding into a reusable helper function
that accepts a callback parameter to handle the differences between the two
tests (specifically how the query is constructed with findOne versus without,
and how the result is accessed). This will eliminate the code duplication and
make the tests more maintainable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4c4da52f-328e-4135-b378-27cbab73e0c8

📥 Commits

Reviewing files that changed from the base of the PR and between 9a5e8e5 and afe89c6.

📒 Files selected for processing (4)
  • .changeset/loose-flies-sell.md
  • packages/db/src/proxy.ts
  • packages/db/tests/proxy.test.ts
  • packages/solid-db/tests/useLiveQuery.test.tsx

'@tanstack/db': patch
---

Fixed a bug where cloning non enumerable properties causes solid store to get stuck in a non current state

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Polish release note wording for clarity.

Use hyphenation and product casing for readability in changelog text.

Suggested edit
-Fixed a bug where cloning non enumerable properties causes solid store to get stuck in a non current state
+Fixed a bug where cloning non-enumerable properties causes the Solid store to get stuck in a non-current state.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Fixed a bug where cloning non enumerable properties causes solid store to get stuck in a non current state
Fixed a bug where cloning non-enumerable properties causes the Solid store to get stuck in a non-current state.
🧰 Tools
🪛 LanguageTool

[grammar] ~6-~6: Use a hyphen to join words.
Context: ...patch --- Fixed a bug where cloning non enumerable properties causes solid store...

(QB_NEW_EN_HYPHEN)


[grammar] ~6-~6: Use a hyphen to join words.
Context: ...causes solid store to get stuck in a non current state

(QB_NEW_EN_HYPHEN)

🤖 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 @.changeset/loose-flies-sell.md at line 6, The release note in the changeset
file needs improved formatting for clarity. Apply hyphenation to compound
adjectives by adding hyphens to "non enumerable" and "non current".
Additionally, apply proper product casing to "solid store" to match standard
product naming conventions. These changes will improve the readability and
professionalism of the changelog entry.

Source: Linters/SAST tools

@fezproof fezproof changed the title Fixed bug with solid not remounting with the right data FIX solid-db, db: bug with solid not remounting with current data due to proxy issues Jun 22, 2026
@fezproof
fezproof force-pushed the solid-remount-fix branch from afe89c6 to e6a99a7 Compare July 22, 2026 15:03
@fezproof
fezproof changed the base branch from main to refactor/live-query-observer July 22, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant