Skip to content

Read current query state when scheduled polls fire - #5412

Merged
markerikson merged 1 commit into
reduxjs:masterfrom
OskarEichler:codex/read-current-polling-state
Sep 19, 2026
Merged

markerikson merged 1 commit into
reduxjs:masterfrom
OskarEichler:codex/read-current-polling-state

Conversation

@OskarEichler

Copy link
Copy Markdown
Contributor

Fixes

  • Read the current RTK Query slice and cache entry inside each polling timeout instead of closing over the scheduling-time Redux snapshot.
  • Honor focus loss that occurs after a poll was scheduled when skipPollingIfUnfocused is enabled.
  • Stop and remove the poll when its cache entry was deleted, rather than refetching through a stale substate and reviving it.

Closes #5411. Related to the broader React Native background-polling request in #5034.

Verification

  • The focus regression waits for the initial request to fulfill (so the poll is already scheduled), then dispatches onFocusLost. On the exact base it makes a second request; after the fix it remains at one.
  • Added a removed-cache regression that verifies the scheduled callback leaves the selector uninitialized and makes no second request.
  • Focused polling suite: ten tests pass with zero type errors.
  • yarn workspace @reduxjs/toolkit test — 88 files, 1,318 passing tests, two existing todos, zero type errors.
  • yarn workspace @reduxjs/toolkit build
  • yarn workspace @reduxjs/toolkit type-tests
  • Prettier check over every changed file
  • git diff --check

Compatibility

No public type, API, option, action, or state-shape change. Poll cadence is unchanged while active/focused; callbacks now apply the documented focus option and current cache lifecycle at firing time.

@codesandbox

codesandbox Bot commented Aug 30, 2026

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web Editor • VS Code • Insiders

Open Preview

@netlify

netlify Bot commented Aug 30, 2026

Copy link
Copy Markdown

✅ Deploy Preview for redux-starter-kit-docs ready!

Name Link
🔨 Latest commit 7c8eb29
🔍 Latest deploy log https://app.netlify.com/projects/redux-starter-kit-docs/deploys/6a93896816850d0009611877
😎 Deploy Preview https://deploy-preview-5412--redux-starter-kit-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@pkg-pr-new

pkg-pr-new Bot commented Sep 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

@reduxjs/rtk-codemods

npm i https://pkg.pr.new/@reduxjs/rtk-codemods@7c8eb29 -D
yarn add https://pkg.pr.new/@reduxjs/rtk-codemods@7c8eb29.tgz -D
pnpm add https://pkg.pr.new/@reduxjs/rtk-codemods@7c8eb29.tgz -D
bun add https://pkg.pr.new/@reduxjs/rtk-codemods@7c8eb29.tgz -D

@rtk-query/codegen-openapi

npm i https://pkg.pr.new/@rtk-query/codegen-openapi@7c8eb29 -D
yarn add https://pkg.pr.new/@rtk-query/codegen-openapi@7c8eb29.tgz -D
pnpm add https://pkg.pr.new/@rtk-query/codegen-openapi@7c8eb29.tgz -D
bun add https://pkg.pr.new/@rtk-query/codegen-openapi@7c8eb29.tgz -D

@rtk-query/graphql-request-base-query

npm i https://pkg.pr.new/@rtk-query/graphql-request-base-query@7c8eb29 -D
yarn add https://pkg.pr.new/@rtk-query/graphql-request-base-query@7c8eb29.tgz -D
pnpm add https://pkg.pr.new/@rtk-query/graphql-request-base-query@7c8eb29.tgz -D
bun add https://pkg.pr.new/@rtk-query/graphql-request-base-query@7c8eb29.tgz -D

@reduxjs/toolkit

npm i https://pkg.pr.new/@reduxjs/toolkit@7c8eb29 -D
yarn add https://pkg.pr.new/@reduxjs/toolkit@7c8eb29.tgz -D
pnpm add https://pkg.pr.new/@reduxjs/toolkit@7c8eb29.tgz -D
bun add https://pkg.pr.new/@reduxjs/toolkit@7c8eb29.tgz -D

commit: 7c8eb29

@markerikson
markerikson merged commit 52a5d57 into reduxjs:master Sep 19, 2026
45 checks passed
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.

Scheduled polls use a stale focus-state snapshot

3 participants