fix(query-core): keep selector error timestamps stable
Merged
TK
13d ago+27+27+01234567890123456789-1-1-0123456789
🎯 Changes
Fixes #12532.
Recomputing a cached selector error changes errorUpdatedAt, which can cause an infinite render loop through React's external-store snapshot checks. Reuse the previous timestamp when the error reference is unchanged.
The regression test fails on main because the timestamp changes after the clock advances. With this fix, all 85 observer tests pass through Nx using existing local dependencies. Formatting checks pass. The full pnpm run test:pr command has not run.
✅ Checklist
- I have followed the steps in the Contributing guide.
- I have tested code changes locally with
pnpm run test:pr, or these tests do not apply to this pull request. - I have followed the AI contribution policy and fully understand the code in this pull request, including any code generated with AI assistance.
🚀 Release Impact
- This change affects published code, and I have generated a changeset.
- This change is docs/CI/dev-only (no release).
Summary by CodeRabbit
- Bug Fixes
- Selector errors now retain their original timestamp when the same error persists, preventing unnecessary result changes and infinite render loops.
- Added coverage for selector errors when cached initial data is present.