Skip to content

fix(vue): invalidate only mounted queries - #864

Merged
patroza merged 2 commits into
mainfrom
vue/active-query-invalidation
Aug 14, 2026
Merged

fix(vue): invalidate only mounted queries#864
patroza merged 2 commits into
mainfrom
vue/active-query-invalidation

Conversation

@omegent-app

@omegent-app omegent-app Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Why

The atom query engine treated idle gcTime cache like mounted queries and refetched them on every own-write. TanStack only refetches active observers (refetchType: "active"). Apps then shrink gcTime (e.g. 30s hub Work) as a workaround, and pay more query RU than the screen needs.

Scanner: https://github.com/macs-holding/scanner/pull/2224

What

  • QueryLifetime on the family atom holds observers + invalidated
  • Invalidate marks idle entries stale and refetches only when observers > 0
  • invalidateAndAwait still waits for those observed refetches to settle
  • Idle entries refetch on remount

invalidateSoft is unchanged: it fires without awaiting.

How

packages/vue/src/queryLifetime.ts + invalidateAndAwait / invalidateSoft use atomsToRefetch. Tests lock: unmounted invalidation does not fetch; mounted invalidation refetches; invalidateAndAwait stays pending until the mounted refetch finishes.

Remarks

  • No writeCollection / intersectsLive work (that is scanner #2223).
  • Changeset: minor @effect-app/vue

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

omegent-app Bot and others added 2 commits August 14, 2026 06:04
Match TanStack refetchType: "active". Idle gcTime entries are marked
stale; invalidateAndAwait still waits for observed refetches.

Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
Co-authored-by: Patrick Roza <42661+patroza@users.noreply.github.com>
@pkg-pr-new

pkg-pr-new Bot commented Aug 14, 2026

Copy link
Copy Markdown

Open in StackBlitz

@effect-app/cli

npm i https://pkg.pr.new/effect-app/libs/@effect-app/cli@864

effect-app

npm i https://pkg.pr.new/effect-app/libs/effect-app@864

@effect-app/eslint-codegen-model

npm i https://pkg.pr.new/effect-app/libs/@effect-app/eslint-codegen-model@864

@effect-app/eslint-shared-config

npm i https://pkg.pr.new/effect-app/libs/@effect-app/eslint-shared-config@864

@effect-app/infra

npm i https://pkg.pr.new/effect-app/libs/@effect-app/infra@864

@effect-app/vue

npm i https://pkg.pr.new/effect-app/libs/@effect-app/vue@864

@effect-app/vue-components

npm i https://pkg.pr.new/effect-app/libs/@effect-app/vue-components@864

commit: e236699

@patroza
patroza marked this pull request as ready for review August 14, 2026 06:18
@patroza
patroza merged commit eddda2e into main Aug 14, 2026
6 checks passed
@patroza
patroza deleted the vue/active-query-invalidation branch August 14, 2026 06:19
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