Explorar el Código

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

Origin-main-commit: c8e2d4adc9112d2529de0434acc1188dfc399bf4
daiwei hace 1 mes
padre
commit
79d5f93060
Se han modificado 1 ficheros con 6 adiciones y 1 borrados
  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