Skip to content

fix(svelte-query): handle multi-item createQueries removals#10342

Open
raashish1601 wants to merge 2 commits intoTanStack:mainfrom
raashish1601:contributor-01/query-10341
Open

fix(svelte-query): handle multi-item createQueries removals#10342
raashish1601 wants to merge 2 commits intoTanStack:mainfrom
raashish1601:contributor-01/query-10341

Conversation

@raashish1601
Copy link
Copy Markdown

@raashish1601 raashish1601 commented Mar 27, 2026

Summary

  • delete proxy-backed array result entries from the tail first so createQueries can shrink by multiple items in one update
  • add a regression that reproduces shrinking a reactive query list from four entries to two
  • add a patch changeset for @tanstack/svelte-query

Testing

  • corepack pnpm --filter @tanstack/svelte-query exec vitest run tests/createQueries.svelte.test.ts
  • corepack pnpm exec eslint packages/svelte-query/src/containers.svelte.ts
  • git diff --check

Fixes #10341.

Summary by CodeRabbit

  • Bug Fixes

    • createQueries now correctly handles removing multiple queries in a single reactive update.
  • Tests

    • Added a test validating removal of multiple queries in one update.
  • Chores

    • Added a changeset entry to publish a patch release.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 07bb340e-6e85-4477-bf86-cb6fd1ca5992

📥 Commits

Reviewing files that changed from the base of the PR and between 29f423f and 387c7b7.

📒 Files selected for processing (1)
  • packages/svelte-query/src/containers.svelte.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/svelte-query/src/containers.svelte.ts

📝 Walkthrough

Walkthrough

A patch adds a changeset and fixes createRawRef in createRawRef to reverse deletion order when the proxied output is an array, preventing crashes when multiple items are removed from a reactive query list; a new test verifies the behavior.

Changes

Cohort / File(s) Summary
Release Documentation
\.changeset/green-peaches-yawn.md
Added a changeset marking a patch release for @tanstack/svelte-query describing the fix for batch removals in createQueries.
Core Fix
packages/svelte-query/src/containers.svelte.ts
Adjusted createRawRef's update/remove loop to iterate removals in reverse order when out is an array to avoid proxy deletion errors when multiple items are removed at once.
Test Coverage
packages/svelte-query/tests/createQueries.svelte.test.ts
Imported reactive helper and added a test "should handle removing multiple queries in a single update" that removes two items in one update and asserts the queries shrink to the expected results.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰
I nibbled at keys, then hopped in reverse,
so deletions don't break the universe.
When queries tumble two-by-two,
I patch the path and stitch it through.
Hooray — the list now hops anew! 🥕✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% 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
Title check ✅ Passed The title 'fix(svelte-query): handle multi-item createQueries removals' directly and accurately summarizes the main change: fixing the handling of multiple item removals in createQueries.
Description check ✅ Passed The PR description provides a clear summary section, testing instructions, and references the fixed issue, but lacks explicit checklist items from the template (Contributing guide, testing, and changeset confirmation).
Linked Issues check ✅ Passed The PR successfully addresses issue #10341 by implementing the tail-first deletion strategy to handle multi-item removals from proxy-backed arrays and includes a regression test covering the reported crash scenario.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the multi-item removal bug: the core fix in containers.svelte.ts, a regression test in createQueries.svelte.test.ts, and the required changeset file.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[svelte-query] createQueries crashes when the several items are removed from the array simultaneously

1 participant