fix(svelte-query): handle shrinking createRawRef array by multiple entries (#10341) - #10892
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughUpdated ChangesArray Shrinking Proxy Fix
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This is a localized fix for array shrinking in Svelte Query with regression coverage and passing checks; no actionable merge-blocking risk remains beyond normal review and validation. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
View your CI Pipeline Execution ↗ for commit de6487a
☁️ Nx Cloud last updated this comment at |
|
Please merge this, this bug is making tanstack query svelte unusable |
…tries (TanStack#10341) The `createRawRef` Proxy used by `createQueries` crashed with `TypeError: 'deleteProperty' on proxy: trap returned falsish for property 'N'` whenever the reactive query list was shrunk by two or more items in one update. Two compounding causes: 1. `update()` iterated `keysToRemove` in ascending index order. The trap decrements `target.length` after every deletion, so the next stale index was no longer `in target` and the trap returned `false`, which throws in strict mode (ES modules). 2. The trap returned `false` for missing props instead of treating delete on a nonexistent prop as a spec-compliant no-op. Fix: sort `keysToRemove` descending for arrays so each delete acts on the current tail, and return `true` from `deleteProperty` when the prop is already absent. Generated by Ora Studio Vibe coded by ousamabenyounes Co-Authored-By: Claude <noreply@anthropic.com>
7a1c6ce to
8c42f49
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Summary
Fix #10341
createQueriescrashed withTypeError: 'deleteProperty' on proxy: trap returned falsish for property 'N'whenever two or more items were removed from its reactive array in a single update. The crash bubbled up from the$effect.preincreateQueries.svelte.ts, but the root cause sits increateRawRef(packages/svelte-query/src/containers.svelte.ts).Root cause
createRawRef.update()iterateskeysToRemovein ascending index order. For arrays, thedeletePropertytrap decrementstarget.lengthon every successful delete — so after the first deletion the next stale index is no longerin target, the trap returnsfalse, anddeletethrows in strict mode (ES modules). The trap was also returningfalsewhen the property was already absent, which is not howdeleteis meant to behave on a missing prop.Fix
Two small, related changes in
packages/svelte-query/src/containers.svelte.ts:keysToRemovenumerically descending whennewValueis an array, so every delete acts on the current tail andlength--stays valid.truefromdeletePropertyfor missing props — the spec semantic fordeleteon an absent property is a no-op, not a strict-mode throw. This makes the trap robust against any other path that might also try to delete a stale index.Both are needed: (1) is the correctness fix; (2) is defense in depth that makes the trap behave like a normal object trap.
Verification
should handle shrinking an array by more than one entry at onceinpackages/svelte-query/tests/containers.svelte.test.ts— shrinks[1, 2, 3, 4, 5]→[1, 2]→[1, 2, 3, 4]→[].mainwith the exact symptom from the issue:TypeError: 'deleteProperty' on proxy: trap returned falsish for property '4'atsrc/containers.svelte.ts:93.@tanstack/svelte-query:test:lib— 22 files, 164 tests, all pass.test:eslintandtest:typesclean.Changeset
@tanstack/svelte-query:patch— runtime bug fix, no public API change.Generated by Ora Studio
Vibe coded by ousamabenyounes
Summary by CodeRabbit