Skip to content

fix(core): prevent React Query double fetching by lazy signal access#7439

Closed
SpencerJung wants to merge 1 commit into
refinedev:mainfrom
SpencerJung:fix/7132-react-query-double-fetch
Closed

fix(core): prevent React Query double fetching by lazy signal access#7439
SpencerJung wants to merge 1 commit into
refinedev:mainfrom
SpencerJung:fix/7132-react-query-double-fetch

Conversation

@SpencerJung

Copy link
Copy Markdown

fix(core): prevent React Query double fetching by lazy signal access

Description

Refine v5's useList and other data hooks perform two HTTP requests in React 18 + Strict Mode in development, while refine v4 performed only one.

Root Cause

Spreading prepareQueryContext(context) inside queryFn invokes the signal getter, causing React Query to detect that signal is used. When signal is used, React Query treats the query as abortable, and in dev + Strict Mode it cancels the first run and issues a second fetch.

Fix

Avoid spreading the object with the signal getter and instead define the lazy getter directly on the meta object, matching v4 behavior.

Changed

  • packages/core/src/hooks/data/useList.ts
  • packages/core/src/hooks/data/useOne.ts
  • packages/core/src/hooks/data/useMany.ts
  • packages/core/src/hooks/data/useCustom.ts
  • packages/core/src/hooks/data/useInfiniteList.ts

Verification

Before fix: 2 network requests in Strict Mode dev
After fix: 1 network request in Strict Mode dev

Related Issue

Closes #7132

In React 18 Strict Mode, spreading prepareQueryContext(context) inside
queryFn invokes the signal getter, causing React Query to treat the
query as abortable and issue a second fetch after cancellation.

This fix avoids spreading the object with the signal getter and instead
defines the lazy getter directly on the meta object, matching v4 behavior.

Affected hooks: useList, useOne, useMany, useCustom, useInfiniteList

Closes refinedev#7132
@changeset-bot

changeset-bot Bot commented May 27, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 1cf67ab

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

@BatuhanW BatuhanW closed this Jun 3, 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.

[BUG] React Query double fetching in Refine v5 caused by unintended signal access (v4 did not do this)

2 participants