-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fix(query-core): fix queriesObserver result and observer length mismatch #9973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
In 1b54538, `setOptions` was changed to call `notifyListeners` which eventually leads to `QueriesObserver.setQueries` 1. Updating `#observerMatches` 2. Calling `setOptions` which leads to `#notify` being called 3. Updating `#result` This is an issue when `#notify` is called before the `#result` is updated, as `#trackResult` assumes these two are the same length, which may not be the case if the number of queries changed. When the length increases, `observerResult` becomes `undefined` and the function throws an exception. Fix by moving the `#observerMatches` assignment later in the function, next to the `#observers` and `#result` assignment.
🦋 Changeset detectedLatest commit: 13e69b0 The changes in this PR will be included in the next version bump. This PR includes changesets to release 19 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
WalkthroughThis PR patches Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used🧠 Learnings (3)📓 Common learnings📚 Learning: 2025-11-22T09:06:05.219ZApplied to files:
📚 Learning: 2025-09-02T17:57:33.184ZApplied to files:
🔇 Additional comments (2)
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 |
🎯 Changes
In 1b54538,
setOptionswas changed to callnotifyListenerswhich eventually leads toQueriesObserver.setQueries#observerMatchessetOptionswhich leads to#notifybeing called#resultThis is an issue when
#notifyis called before the#resultis updated, as#trackResultassumes these two are the same length, which may not be the case if the number of queries changed. When the length increases,observerResultbecomesundefinedand the function throws an exception.Fix by moving the
#observerMatchesassignment later in the function, next to the#observersand#resultassignment. I don't know the full nuances of this code so please advise if there's a better solution.✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.