Conversation
… stopped matching filter Object.assign copies enumerable own properties but never sets Array.length. When nextResult was shorter than result (fewer mutations matched the filter), trailing stale entries were never removed — the array only ever grew. Fix: replace Object.assign with result.splice(0, result.length, ...nextResult). splice keeps the reactive $state array reference intact (required by Svelte 5 runes) while correctly adjusting length, adding, and removing elements. Adds a regression test: two pending mutations, both settle, assert the filtered result shrinks to []. Fixes TanStack#11152
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthrough
ChangesMutation state filtering
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to The mutation-state result now removes settled mutations while retaining the reactive array reference, with regression coverage for the reported failure. No actionable merge risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 unsupported.)
✨ 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 |
Summary
Object.assigncopies enumerable own properties but never setsArray.length. WhennextResultwas shorter thanresult(fewer mutations matched the filter), trailing stale entries were never removed — the array only ever grew.Fix: replace
Object.assign(result, nextResult)withresult.splice(0, result.length, ...nextResult).splicekeeps the reactive$statearray reference intact (required by Svelte 5 runes) while correctly adjusting length, adding, and removing elements in one operation.Fixes #11152
Changes
packages/svelte-query/src/useMutationState.svelte.ts— one-line fixpackages/svelte-query/tests/useMutationState/useMutationState.svelte.test.ts— regression test: two pending mutations both settle, assert the filtered result shrinks to[].changeset/fix-svelte-use-mutation-state-shrink.md— patch changesetTest plan
pnpm --filter @tanstack/svelte-query testThe new test (
should remove mutations that no longer match the filter) would have failed before this fix.Summary by CodeRabbit
Bug Fixes
Tests