Skip to content

fix(vue): read the async data on screen again when its scope moves - #388

Merged
Upd4ting merged 5 commits into
mainfrom
fix/w5a773c8b-2-async-data-scope-refetch
Nov 20, 2026
Merged

Upd4ting merged 5 commits into
mainfrom
fix/w5a773c8b-2-async-data-scope-refetch

Conversation

@Upd4ting

Copy link
Copy Markdown
Member

W5a773c8b-2, root cause of W5a773c8b-1 (the dms-saas sidebar workspace switcher loading forever after the session's account or workspace changes without a page reload).

⚠ sensitive: changes what async data a component shows across an account or workspace switch (tenancy isolation of cached data)

Summary

When the async data scope moves, data a caller still shows is now read again in the new scope.

Before, setDmsAsyncDataScope cleared every keyed entry and emptied runtime.asyncData. A component still on screen kept its cleared entry (status idle, data null), and nothing read it again until the component's own key changed. In dms-saas, reconcileSession moves the scope after another tab switches account, and the workspace switcher at /api/saas/workspaces/mine stayed loading. A call without a key was not in the map at all, so it kept the previous scope's data under the new scope.

setDmsAsyncDataScope now walks runtime.boundAsyncData, the entries some caller shows:

  • It clears every entry, so no data of the previous scope stays on screen, and the clear aborts each run in flight, so a late answer of the previous scope settles nothing.
  • It stores each shown keyed entry back under its key in the new scope, so useDmsData and a new caller of the key share it.
  • It reads again each entry that had loaded or was loading. Data a caller waits to execute() stays unread.

A caller with a reactive key shows the previous key's data until its new key settles. When the scope moved during that wait, it kept showing the previous scope's data. It now drops that data once its current key leaves pending, so a clear back to idle drops it too.

runtime.boundAsyncData is now typed as the set of entries it holds. That type is internal to the runtime, so no caller changes.

flowchart TD
  S["setDmsAsyncDataScope(other)"] --> C[collect the entries a caller shows, noting which had loaded or were loading]
  C --> X[clear every entry: default data, runs aborted]
  X --> K[store each shown keyed entry under its key in the new scope]
  K --> L{had it loaded or was it loading?}
  L -->|yes| R["load(): status pending, then the new scope's data"]
  L -->|"no (waits for execute())"| I[stays idle]
Loading

Related issue

W5a773c8b-2, from W5a773c8b-1. No GitHub issue: the orchestrator tracks the task.

Verification

Tests in tests/vue-async-data-revalidate-scope.test.mts, describe("Async data on a scope move").

Before, data-access.ts and async-data.ts as on main (data-access.ts is the same as on v0.11.8):

  ✖ reads again, in the new scope, the data a mounted component shows
  ✖ reads again, in the new scope, the data a call without a key shows
  ✖ never lets a late answer of the previous scope replace the new one
  ✖ drops the previous key's data a reactive key carries into the new scope
  ✔ leaves the data a component waits to execute() unread in the new scope
ℹ pass 1
ℹ fail 4
    actual: 'idle:null'
    expected: 'success:plan of b'
    actual: 'plan of a'
    expected: null
    actual: 'idle:null'
    expected: 'success:plan of b'
    actual: 'first of a'
    expected: null

After:

  ✔ reads again, in the new scope, the data a mounted component shows
  ✔ reads again, in the new scope, the data a call without a key shows
  ✔ never lets a late answer of the previous scope replace the new one
  ✔ drops the previous key's data a reactive key carries into the new scope
  ✔ leaves the data a component waits to execute() unread in the new scope

Each test fails on a wrong implementation, checked by mutating the fix: loading every shown entry fails the execute() test; skipping the clear fails the mounted-component and late-answer tests; storing nothing back under the new scope fails the mounted-component test (useDmsData finds nothing); clearing only the keyed map fails the keyless test; dropping carried data only once the new key settles fails the reactive-key test.

Local: pnpm run typecheck passes, oxlint and oxfmt pass on the changed files, pnpm test (4 workers) runs 991 tests with 0 failures.

Attention

  • A scope change on the server after its render has finished starts reads that nobody waits for, so the transferred payload holds the new scope's key while the HTML shows the old one. The TSDoc already says to set the scope before the page renders, so only a caller that ignores it hits this.

Checklist

  • The pull request title follows Conventional Commits.
  • I added or updated tests when behavior changed.
  • I updated documentation when users or contributors are affected.
  • I documented breaking changes and migration steps. None: a patch.
  • I did not include credentials or unrelated changes.

Follow-ups

  • none

@Upd4ting
Upd4ting marked this pull request as ready for review November 20, 2026 14:43
@Upd4ting
Upd4ting enabled auto-merge November 20, 2026 14:43
@Upd4ting
Upd4ting added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 5775697 Nov 20, 2026
12 checks passed
@Upd4ting
Upd4ting deleted the fix/w5a773c8b-2-async-data-scope-refetch branch November 20, 2026 14:59
Upd4ting added a commit to AntelopeJS/dms-saas that referenced this pull request Nov 20, 2026
Pin @antelopejs/dms-frontend 0.11.9-next.318.g5775697 (AntelopeJS/dms-frontend#388).
Its setDmsAsyncDataScope keeps the data that mounted readers show under
the new account and workspace and reads it again, instead of leaving it
idle. The sidebar switcher stays mounted across an account change made
without a page reload, so on 0.11.8 it showed its skeleton forever.
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