Kaynağa Gözat

fix(runtime-core): cleanup stopped async setup scopes

Origin-main-commit: c8e2d4adc9112d2529de0434acc1188dfc399bf4
daiwei 1 ay önce
ebeveyn
işleme
79d5f93060
1 değiştirilmiş dosya ile 6 ekleme ve 1 silme
  1. 6 1
      packages/runtime-core/src/apiSetupHelpers.ts

+ 6 - 1
packages/runtime-core/src/apiSetupHelpers.ts

@@ -548,11 +548,16 @@ export function withAsyncContext(getAwaitable: () => any): [any, () => void] {
   }
 
   const restore = () => {
+    const resetStoppedScope = ctx && !ctx.scope.active ? ctx.scope : undefined
     setCurrentInstance(ctx)
     if (inSSRSetup) {
       setInSSRSetupState(true)
     }
-    return restoreAsyncContext && restoreAsyncContext()
+    const reset = restoreAsyncContext && restoreAsyncContext()
+    return () => {
+      if (reset) reset()
+      if (resetStoppedScope) resetStoppedScope.reset()
+    }
   }
 
   // Never restore a captured "prev" instance here: in concurrent async setup