Skip to content

fix(core): keep query context signal lazy when merging meta#7355

Open
Dailin521 wants to merge 2 commits intorefinedev:mainfrom
Dailin521:fix/lazy-query-context-signal
Open

fix(core): keep query context signal lazy when merging meta#7355
Dailin521 wants to merge 2 commits intorefinedev:mainfrom
Dailin521:fix/lazy-query-context-signal

Conversation

@Dailin521
Copy link
Copy Markdown

Summary

This keeps queryContext.signal lazy when merging query context into meta.

Previously we spread prepareQueryContext(context) into a new meta object inside multiple core data hooks. Because signal is defined as a getter, object spread eagerly accessed it during merge. That marks the query as abortable earlier than intended and can trigger the duplicate request behavior described in #7132.

Closes #7132.

Changes

  • update prepareQueryContext to accept an optional meta object and merge into it internally
  • preserve signal as a lazy getter on the returned object
  • switch affected hooks to use the helper directly:
    • useList
    • useOne
    • useMany
    • useInfiniteList
    • useCustom
  • add a regression test for lazy signal access

Validation

  • corepack pnpm --filter @refinedev/devtools-shared --filter @refinedev/devtools-internal build
  • corepack pnpm --dir packages/core test -- src/definitions/helpers/prepare-query-context/index.spec.ts src/hooks/data/useList.spec.tsx src/hooks/data/useOne.spec.tsx src/hooks/data/useMany.spec.tsx src/hooks/data/useCustom.spec.tsx src/hooks/data/useInfiniteList.spec.tsx
  • corepack pnpm --dir packages/core build

@Dailin521 Dailin521 requested a review from a team as a code owner March 20, 2026 06:48
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 20, 2026

🦋 Changeset detected

Latest commit: 7ecac9c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@refinedev/core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Dailin521
Copy link
Copy Markdown
Author

This PR is still intentionally narrow to the lazy queryContext.signal merge path in @refinedev/core.

Verification I ran is listed in the PR body and covers the targeted helper test, affected hook tests, and the package build. If there is any preferred adjustment to the approach or scope, I can update it quickly.

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)

1 participant