Skip to content

fix(query-devtools): isolate signals on devtools instances - #11799

Open
DogPawHat wants to merge 5 commits into
TanStack:mainfrom
DogPawHat:isolate-devtool-instances
Open

DogPawHat wants to merge 5 commits into
TanStack:mainfrom
DogPawHat:isolate-devtool-instances

Conversation

@DogPawHat

@DogPawHat DogPawHat commented Oct 1, 2026 •

Copy link
Copy Markdown
Collaborator

🎯 Changes

Solves #9681

Each instance of DevTools now isolates signals to that instance instead of declaring them on the module level, creating signals on the module level that are shared across all instances.

This breaks scenarios where you need to be running two instances of query DevTools alongside each other.

I've broken the state up into three different providers and contexts:

  • DevtoolsStateProvider: grouped together 3 signals and puts there accesscors and setters into context
  • DevtoolsOfflineProvider: groups the offline signal with the effect that subscribes to the passed in onlineManager from Query
  • DevtoolsSubscriptionsProvider: manages the two maps of subscriptions to queries and mutations.

And regression tests have been added as well.

Better diff viewer: https://diffshub.com/TanStack/query/pull/11799
Edited reproducer from the issue: https://stackblitz.com/edit/tanstack-react-query-dev-tools-issue-fvstvhn8?file=package.json,src%2FApp.tsx

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with pnpm run test:pr, or these tests do not apply to this pull request.
  • I have followed the AI contribution policy and fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • Bug Fixes
    • DevTools instances now keep query and mutation selections, panel widths, and offline status independent, preventing changes in one instance from affecting another.
    • Cache updates are isolated between instances, and updates from subscriptions that have been closed are ignored.
    • Offline status and cache notifications remain consistent when instances share a query client.

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: TanStack/query/.coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 08e5268d-dd5b-4fde-bb7d-968478ca17a7

📥 Commits

Reviewing files that changed from the base of the PR and between 782b2e6 and 58685f3.

📒 Files selected for processing (14)
  • .changeset/quiet-panels-stay-independent.md
  • packages/query-devtools/src/Devtools.tsx
  • packages/query-devtools/src/DevtoolsComponent.tsx
  • packages/query-devtools/src/DevtoolsPanelComponent.tsx
  • packages/query-devtools/src/__tests__/Devtools.test.tsx
  • packages/query-devtools/src/__tests__/createCacheSubscriptionRegistry.test.ts
  • packages/query-devtools/src/contexts/DevtoolsOfflineContext.ts
  • packages/query-devtools/src/contexts/DevtoolsStateContext.ts
  • packages/query-devtools/src/contexts/DevtoolsSubscriptionsContext.ts
  • packages/query-devtools/src/contexts/types.ts
  • packages/query-devtools/src/createCacheSubscriptionRegistry.ts
  • packages/query-devtools/src/providers/DevtoolsOfflineProvider.tsx
  • packages/query-devtools/src/providers/DevtoolsStateProvider.tsx
  • packages/query-devtools/src/providers/DevtoolsSubscriptionsProvider.tsx

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

DevTools now provides selection state, panel width, offline status, and cache subscriptions through contexts. Full and embedded DevTools trees mount the providers. Tests cover state and subscription isolation across instances.

Changes

DevTools state and subscriptions

Layer / File(s) Summary
Define contexts and providers
packages/query-devtools/src/contexts/*, packages/query-devtools/src/providers/*, packages/query-devtools/src/createCacheSubscriptionRegistry.ts
Added contexts and providers for selected items, panel width, offline status, and query and mutation cache subscriptions. The subscription registry filters events and skips updates for removed subscriptions.
Use contexts in DevTools
packages/query-devtools/src/Devtools.tsx, packages/query-devtools/src/DevtoolsComponent.tsx, packages/query-devtools/src/DevtoolsPanelComponent.tsx
DevTools components read state and offline status from contexts. Cache listeners notify subscription registries; query notifications are batched, and mutation updates run in microtasks while their subscriptions remain active. Both component trees mount the providers.
Check instance isolation
packages/query-devtools/src/__tests__/*, .changeset/quiet-panels-stay-independent.md
Tests cover panel widths, query and mutation state, offline status, client changes, cache updates, and cleanup across instances. The Changeset declares a patch release for @tanstack/query-devtools.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 58685

The change isolates DevTools state and subscriptions between instances, with regression coverage for isolation and cleanup. No actionable merge-blocking issue is established; merge after normal checks pass.

Security Architecture Review

Security architecture risk: ⚪ Minimal · up to 58685

The reviewed changes improve instance isolation and cleanup without expanding the data access or control available to DevTools. Shared online managers remain shared intentionally.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The assessed control scope remains the QueryClient supplied to each DevTools tree and any consumers sharing its supplied online manager. Instance-local UI state does not establish a tenant or authorization boundary.

Trust Boundaries and Controls

  • observed — The offline button delegates the pre-existing online-manager toggle to a provider. That provider reads the same supplied manager and exposes an inverse-online operation rather than additional manager authority.

Resilience and Maintainability Implications

  • inferred — Per-instance registries and deferred-update guards reduce cross-instance notification interference and prevent disposed listener generations from applying queued mutation updates after client replacement.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 13 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: isolating signals across DevTools instances.
Description check ✅ Passed The description explains the motivation, implementation, tests, and release impact. It includes all required template sections and marks the applicable checklist items.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 13 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

@nx-cloud

nx-cloud Bot commented Oct 1, 2026 •

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 58685f3

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 2m 21s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2026-10-01 16:58:28 UTC

@pkg-pr-new

pkg-pr-new Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
More templates

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@11799

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@11799

@tanstack/lit-query

npm i https://pkg.pr.new/@tanstack/lit-query@11799

@tanstack/preact-query

npm i https://pkg.pr.new/@tanstack/preact-query@11799

@tanstack/preact-query-devtools

npm i https://pkg.pr.new/@tanstack/preact-query-devtools@11799

@tanstack/preact-query-persist-client

npm i https://pkg.pr.new/@tanstack/preact-query-persist-client@11799

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@11799

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@11799

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@11799

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@11799

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@11799

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@11799

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@11799

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@11799

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@11799

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@11799

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@11799

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@11799

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@11799

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@11799

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@11799

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@11799

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@11799

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@11799

commit: 58685f3

@DogPawHat
DogPawHat marked this pull request as ready for review October 1, 2026 16:54

This branch has not been deployed

No deployments
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