fix #2629: avoid multiple rerenders when tags is an array
✅ Checklist
- [x] I have followed every step in the contributing guide
- [x] The PR title follows the convention
- [x] I ran and verified the fix works as expected
🧪 Testing
I ran the project locally and confirmed that infinite re-renders are no longer happening.
The subscription now initializes once and remains stable, even when using tag arrays.
🧾 Changelog
Fixed an issue causing infinite re-renders by ensuring the tag dependency in the useRealtimeRunsWithTag hook is stable.
React was previously interpreting a new array reference each render (due to shallow comparison), which triggered unnecessary re-subscriptions.
📸 Screenshots
No visual changes — purely internal stability improvement.
💯
fixes #2629
⚠️ No Changeset found
Latest commit: 49d69202214578abc99a1363eb5f6ca548902aed
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
This PR includes no changesets
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
Walkthrough
The change modifies the useRealtimeRunsWithTag hook to normalize tag dependencies by introducing a stableTag variable that sorts and stringifies array-format tags, while preserving non-array tags unchanged. This stableTag replaces the original tag in the hook's effect dependency array and cleanup trigger points, preventing unnecessary re-executions when tag arrays contain identical elements in different orders.
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~10 minutes
Pre-merge checks and finishing touches
✅ Passed checks (3 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title Check | ✅ Passed | The title "fix: avoid multiple rerenders when tags is an array" directly and clearly describes the main change documented in the raw summary: fixing an issue where tag arrays triggered unnecessary re-renders by introducing stable tag dependency tracking. The title uses standard commit convention format, is concise and specific, and a teammate reviewing history would immediately understand that this fixes a re-render performance issue related to array tags. The title is fully related to the core objective of the changeset. |
| Description Check | ✅ Passed | The pull request description is mostly complete and comprehensive, including a fully completed checklist confirming adherence to the contributing guide and PR title convention, a detailed Testing section describing local verification that re-renders no longer occur, a clear Changelog section explaining the fix and its root cause, and an appropriate Screenshots section noting no visual changes. The description is well-structured and provides sufficient context for reviewers to understand the change. The only missing element from the template is the "Closes # |
| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
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 @coderabbitai help to get the list of available commands and usage tips.
NOTE: temporary fixed it by memoizing my tags. Altho it works I dont think it should be the real fix as it is forcing your users to unnecessarily memoize their tags