Skip to content

fix(vue-query): avoid mounting QueryClient on server#10839

Closed
raashish1601 wants to merge 1 commit into
TanStack:mainfrom
raashish1601:fix/vue-query-environment-manager-2
Closed

fix(vue-query): avoid mounting QueryClient on server#10839
raashish1601 wants to merge 1 commit into
TanStack:mainfrom
raashish1601:fix/vue-query-environment-manager-2

Conversation

@raashish1601
Copy link
Copy Markdown
Contributor

@raashish1601 raashish1601 commented May 30, 2026

Summary

  • Use @tanstack/query-core environmentManager.isServer() in VueQueryPlugin install path instead of importing deprecated isServer flag.
  • Add regression test ensuring custom QueryClient is not mounted when running in a server environment.

This keeps SSR behavior explicit and aligned with environmentManager runtime detection.

Summary by CodeRabbit

  • Bug Fixes

    • Improved query client initialization to properly detect and respond to server-side rendering environments using updated environment detection.
  • Tests

    • Added test coverage verifying query client behavior in server-side rendering scenarios, ensuring mount operations are properly controlled.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 30, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c45ff4c4-3e12-4faf-9d7c-afc64372ac8e

📥 Commits

Reviewing files that changed from the base of the PR and between 7fa2781 and c0b26ca.

📒 Files selected for processing (2)
  • packages/vue-query/src/__tests__/vueQueryPlugin.test.ts
  • packages/vue-query/src/vueQueryPlugin.ts

📝 Walkthrough

Walkthrough

VueQueryPlugin now detects server environments using environmentManager.isServer() from @tanstack/query-core instead of a static isServer flag. A test validates that the query client is not mounted in server environments.

Changes

Server Environment Detection Refactor

Layer / File(s) Summary
Server environment detection implementation
packages/vue-query/src/vueQueryPlugin.ts
The plugin imports environmentManager and uses environmentManager.isServer() to conditionally mount the query client, replacing the previous static isServer flag.
Server mount behavior test
packages/vue-query/src/__tests__/vueQueryPlugin.test.ts
A new test verifies that VueQueryPlugin skips mounting the query client in server environments by setting server state via environmentManager.setIsServer and asserting mount is not called.

Possibly related issues

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 Server-side detection takes a turn,
No more static flags to discern—
EnvironmentManager holds the key,
Dynamic checks now set clients free!
✨ A test hops in to make sure it's right.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@raashish1601
Copy link
Copy Markdown
Contributor Author

This appears to be a duplicate of #10832 (same VueQueryPlugin environmentServer fix, same file changes; only minor test wording/location differences). Closing to avoid duplicate coverage.

@raashish1601
Copy link
Copy Markdown
Contributor Author

Duplicate of #10832

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