Skip to content

fix(query-core): preserve null infinite page params - #11527

Open
gwagjiug wants to merge 2 commits into
TanStack:mainfrom
gwagjiug:fix/infinite-query-null-page-param
Open

gwagjiug wants to merge 2 commits into
TanStack:mainfrom
gwagjiug:fix/infinite-query-null-page-param

Conversation

@gwagjiug

@gwagjiug gwagjiug commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

🎯 Changes

Infinite-query refetches reuse the stored first pageParam, falling back to the current initialPageParam only when no stored value exists. The implementation used ??, so a valid stored null page parameter was treated as missing and replaced when initialPageParam later changed.

  • Fall back to initialPageParam only when the stored first page parameter is undefined.
  • Add a regression test that fetches with null, changes initialPageParam, and verifies the refetch still uses the stored null value.
  • Add a patch changeset for @tanstack/query-core.

Validation: pnpm run test:pr with Node 24.16.0 (209 tasks passed).

✅ 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 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
    • Infinite queries now preserve a stored null first-page parameter when refetched, even if a different initial parameter is provided.
    • The initial page parameter is used only when no previous page parameter is stored.

@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 29c4ff9b-8712-4396-8017-36938baf2325

📥 Commits

Reviewing files that changed from the base of the PR and between 8a28904 and 90bab86.

📒 Files selected for processing (3)
  • .changeset/null-page-param-refetch.md
  • packages/query-core/src/__tests__/infiniteQueryBehavior.test.tsx
  • packages/query-core/src/infiniteQueryBehavior.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The first-page parameter selection now preserves a stored null during infinite-query refetches. A regression test covers refetching with a different initialPageParam, and a patch changeset documents the fix.

Changes

Infinite-query refetch behavior

Layer / File(s) Summary
Preserve null first page parameter
packages/query-core/src/infiniteQueryBehavior.ts, packages/query-core/src/__tests__/infiniteQueryBehavior.test.tsx, .changeset/null-page-param-refetch.md
The first-page selection falls back only when the stored parameter is undefined. The test verifies that null remains in pageParams after refetch. The changeset declares a patch release.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 90bab

The refetch behavior is covered by the new regression test, with no remaining concrete merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning 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 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the main change: preserving null infinite-query page parameters during refetch.
Description check ✅ Passed The description follows the required template, explains the behavior change and motivation, documents the regression test and changeset, and completes the checklist.
Full details: Docstring Coverage

Explanation

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)
  • Create a new PR

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.

@gwagjiug gwagjiug changed the title fix(query-core): preserve null infinite page params 🤖🤖🤖 fix(query-core): preserve null infinite page params Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant