Repository navigation
fix(vue-i18n-core): remove local composer when Suspense discards a pending branch - #2796
Conversation
β¦nding branch closes intlify#2795
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
@intlify/core
@intlify/core-base
@intlify/devtools-types
@intlify/message-compiler
petite-vue-i18n
@intlify/shared
vue-i18n
@intlify/vue-i18n-core
commit: |
|
Thank you for the PR and the clear reproduction! We checked it, and it fixes the reported case. We will merge it. The same cause leaves a few more cases, so we will fix them in a follow-up PR:
Thanks! |
Description
Fixes #2795 on the v11 line.
A component that calls
useI18n()with a local scope is removed from__instancesonly inonUnmounted. When<Suspense>discards a branch whose asyncsetup()is still pending, Vue stops the component's effect scope but drops the branch's post-render jobs, soonUnmountednever runs and the component stays in the registry, along with its DOM and listeners.This change registers the deletion on the owning component's effect scope right after
__setInstance:instance.scope), notgetCurrentScope(), so stopping a nestedeffectScope()created insidesetup()does not remove the composer of a component that is still mounted.onUnmountedcleanup stays; deleting twice is a no-op.instance.scopeexists at runtime since Vue 3.2 but is not in Vue's published types, so the change uses a local type assertion.master(v12) already handles this throughonScopeDispose(fix:useI18nimplementation with provide-inject fullyΒ #2357). This is the smallest equivalent for v11, which many apps still use with Vue 3.5.Not changed: the optional
__composerExtenddisposer still runs only inonUnmounted, so an extension that allocates during setup could still skip its dispose on a discarded branch. Happy to move it too if you prefer.Linked Issues
Fixes #2795. Reproduction: https://github.com/FADL285/vue-i18n-suspense-repro
Additional context
Tests added to
packages/vue-i18n-core/test/issues.test.ts(#2795):effectScope()insidesetup()is stopped: the component keeps its local translations until a normal unmount, which still cleans up.issues.test.tsandi18n.test.ts: 104 tests pass. Prettier andgit diff --checkare clean.