Skip to content

Fix query loading state after skipped cache removal#5301

Open
puneetdixit200 wants to merge 1 commit into
reduxjs:masterfrom
puneetdixit200:fix/5300-query-remount-loading
Open

Fix query loading state after skipped cache removal#5301
puneetdixit200 wants to merge 1 commit into
reduxjs:masterfrom
puneetdixit200:fix/5300-query-remount-loading

Conversation

@puneetdixit200

Copy link
Copy Markdown

Summary

Fixes #5300.

When a hook is skipped, it keeps the last successful result so the skipped state can still expose previous data. If that cache entry is removed while skipped, unskipping should treat the next request as a fresh load instead of reusing the stale skipped result.

This resets the hook's last result when the current query state is uninitialized because the cache entry disappeared while skipped, while preserving the existing behavior for normal arg changes that intentionally keep previous data during a new fetch.

Tests

  • yarn workspace @reduxjs/toolkit vitest --run src/query/tests/buildHooks.test.tsx -t 'unskipping a removed query cache entry restarts as an initial load'
  • yarn workspace @reduxjs/toolkit vitest --run src/query/tests/buildHooks.test.tsx
  • yarn workspace @reduxjs/toolkit vitest --run src/query/tests/buildThunks.test.tsx src/query/tests/cacheCollection.test.ts
  • yarn workspace @reduxjs/toolkit test
  • DISABLE_V8_COMPILE_CACHE=1 yarn workspace @reduxjs/toolkit eslint src/query/react/buildHooks.ts src/query/tests/buildHooks.test.tsx
  • yarn prettier --check packages/toolkit/src/query/react/buildHooks.ts packages/toolkit/src/query/tests/buildHooks.test.tsx
  • yarn workspace @reduxjs/toolkit build
  • git diff --check

@codesandbox

codesandbox Bot commented May 22, 2026

Copy link
Copy Markdown

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@netlify

netlify Bot commented May 22, 2026

Copy link
Copy Markdown

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

Name Link
🔨 Latest commit 9e59630
🔍 Latest deploy log https://app.netlify.com/projects/redux-starter-kit-docs/deploys/6a1f3bd80718780007d7a536
😎 Deploy Preview https://deploy-preview-5301--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.

@codesandbox-ci

codesandbox-ci Bot commented May 22, 2026

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 9e59630:

Sandbox Source
@examples-query-react/basic Configuration
@examples-query-react/advanced Configuration
@examples-action-listener/counter Configuration
rtk-esm-cra Configuration

@aryaemami59 aryaemami59 added the RTK-Query Issues related to Redux-Toolkit-Query label May 30, 2026
@puneetdixit200

puneetdixit200 commented Jun 2, 2026

Copy link
Copy Markdown
Author

Pushed 776af49 to make the published-artifact browser examples install Chromium explicitly before running Playwright.

The four failing jobs (cra4, cra5, next, and vite) all reached yarn test and failed at Playwright launch because the expected Chromium executable was missing from the runner cache. The node and native published-artifact examples already passed, so the install step is limited to the Playwright-based examples.

Local checks:

  • git diff --check
  • YAML parse for .github/workflows/tests.yml

The new GitHub Actions runs are currently waiting for fork-run approval before they can execute.

@puneetdixit200

puneetdixit200 commented Jun 2, 2026

Copy link
Copy Markdown
Author

Pushed 829995d with a follow-up CI tweak.

The previous browser-install step reached Playwright, but yarn playwright install --with-deps chromium failed before downloading the browser because Ubuntu 24.04 no longer has a direct libasound2 package candidate. The original failure was only a missing Chromium binary in the runner cache, so this now runs yarn playwright install chromium and avoids Playwright's apt dependency install path.

Checked locally:

  • git diff --check
  • YAML parse for .github/workflows/tests.yml

@puneetdixit200

puneetdixit200 commented Jun 2, 2026

Copy link
Copy Markdown
Author

Pushed 0db95f4 after checking the current-head logs.

The next/cra5 jobs showed Chromium downloading during the initial yarn install, but the later Playwright test still failed because the expected executable under ~/.cache/ms-playwright/chromium-1048 was missing. The explicit install step only fetched ffmpeg, which suggests Playwright saw a stale or incomplete Chromium cache entry.

The workflow now clears ~/.cache/ms-playwright/chromium-* immediately before yarn playwright install chromium, so the explicit step has to restore the Chromium browser used by the test runner.

Checked locally:

  • git diff --check
  • YAML parse for .github/workflows/tests.yml

@puneetdixit200

Copy link
Copy Markdown
Author

Pushed 2ee7cb1 with another published-artifact CI follow-up.

The current-head logs showed yarn playwright install chromium downloading Chromium, but the step returned before the expected executable existed under ~/.cache/ms-playwright/chromium-1048, so the later Playwright launch still failed.

This now uses PLAYWRIGHT_BROWSERS_PATH=0 for the published-artifact matrix so the browser install and test runner both use the example-local Playwright browser path instead of the shared runner cache. The install step also checks chromium.executablePath() immediately after install so any browser-install issue fails at that step with the resolved path.

Checked locally:

  • git diff --check origin/master...HEAD
  • YAML parse for .github/workflows/tests.yml

actionlint is not installed in my local environment, so I could not run that linter locally.

@puneetdixit200 puneetdixit200 force-pushed the fix/5300-query-remount-loading branch from 1c3b987 to 6f03da2 Compare June 2, 2026 18:34
@puneetdixit200

Copy link
Copy Markdown
Author

Pushed 6f03da2 with one more Playwright install follow-up.

The current-head logs showed the example-local path from PLAYWRIGHT_BROWSERS_PATH=0 was being used, but after yarn remove / yarn add mutated node_modules, yarn playwright install chromium still only fetched ffmpeg and left node_modules/playwright-core/.local-browsers/chromium-1048/chrome-linux/chrome missing.

The install step now uses yarn playwright install --force chromium so the explicit post-build install recreates Chromium in the same local browser path that the test runner resolves.

Checked locally:

  • git diff --check upstream/master...HEAD
  • YAML parse for .github/workflows/tests.yml

actionlint is not installed locally, so I could not run that workflow linter here.

@puneetdixit200

Copy link
Copy Markdown
Author

Pushed fc60c22 with another published-artifact CI follow-up.

The current-head logs showed that PLAYWRIGHT_BROWSERS_PATH=0 was resolving to the example-local browser directory, but yarn playwright install --force chromium still only downloaded ffmpeg and then failed the immediate executable check because node_modules/playwright-core/.local-browsers/chromium-1048/chrome-linux/chrome was missing.

This update skips Playwright browser download during the initial example dependency install, then removes the resolved Chromium browser directory immediately before the explicit yarn playwright install chromium step. That avoids reusing a partial local browser directory after the workflow mutates node_modules with the packaged artifact install.

Checked locally:

  • git diff --check upstream/master...HEAD
  • YAML parse for .github/workflows/tests.yml

actionlint is not installed locally, so I could not run that workflow linter here.

@puneetdixit200

Copy link
Copy Markdown
Author

Pushed 829938c after the approved run produced fresh logs.

The updated vite and cra4 jobs confirmed that PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 was applied during dependency install and that Chromium downloaded to 100% in the explicit install step, but the package-local .local-browsers executable was still missing immediately afterward.

This moves PLAYWRIGHT_BROWSERS_PATH out of node_modules to the runner temp directory for the published-artifact job, clears that Chromium cache before the explicit install, and keeps the immediate executable check before yarn test.

Checked locally:

  • git diff --check upstream/master...HEAD
  • YAML parse for .github/workflows/tests.yml

actionlint is not installed locally, so I could not run that workflow linter here.

@puneetdixit200

Copy link
Copy Markdown
Author

Pushed 7a68114 to fix the workflow parser issue from the previous commit.

The runner context is not available in that job-level env expression, so the browser path now uses a fixed Ubuntu temp directory instead. Local validation still passes:

  • git diff --check upstream/master...HEAD
  • YAML parse for .github/workflows/tests.yml

@puneetdixit200

Copy link
Copy Markdown
Author

Pushed c3aff79 after inspecting the current-head logs from the approved run.

The failed Playwright rows now show PLAYWRIGHT_BROWSERS_PATH=/tmp/playwright-browsers, the browser install command downloading Chromium to 100%, and then the immediate executable check failing before yarn test. This keeps the stable temp browser path and changes the check to wait up to 30 seconds for the resolved Chromium executable before failing with that path.

Checked locally:

  • git diff --check upstream/master...HEAD
  • YAML parse for .github/workflows/tests.yml

actionlint is not installed locally, so I could not run that workflow linter here.

@puneetdixit200

Copy link
Copy Markdown
Author

Pushed 80bd04e after the current-head logs showed the 30-second wait still expired.

The failure is now clearly before yarn test: Playwright reports the Chromium download, but no executable is created at the resolved browser path even after waiting. This update derives the Chromium revision/path from Playwright, downloads the same Chromium archive directly, extracts it with Python into the resolved browser directory, chmods the executable, and keeps the immediate Playwright path check before tests.

Checked locally:

  • git diff --check upstream/master...HEAD
  • YAML parse for .github/workflows/tests.yml

actionlint is not installed locally, so I could not run that workflow linter here.

@puneetdixit200

Copy link
Copy Markdown
Author

The current head is green now.

On 80bd04ed, the published-artifact browser rows that were failing before all completed successfully:

  • Test Published Artifact cra4
  • Test Published Artifact cra5
  • Test Published Artifact next
  • Test Published Artifact vite

The rest of the visible check set is success, skipped, or neutral, and the PR merge state is clean.

@aryaemami59

aryaemami59 commented Jun 2, 2026

Copy link
Copy Markdown
Member

I've opened #5310 to fix the CI failures caused by the Playwright browser tests.

@puneetdixit200 puneetdixit200 force-pushed the fix/5300-query-remount-loading branch from 80bd04e to 9e59630 Compare June 2, 2026 20:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

RTK-Query Issues related to Redux-Toolkit-Query

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RTK Query] removeQueryResult deletes entry instead of resetting to uninitialized, breaking isLoading semantics

2 participants