Skip to content

Commit 3728edd

Browse files
mitaraJean
authored andcommitted
fix: make sure global state is restored in the case of an exception in macrotask callback (vuejs#9093)
1 parent 5649486 commit 3728edd

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/core/util/next-tick.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ if (typeof Promise !== 'undefined' && isNative(Promise)) {
8181
export function withMacroTask (fn: Function): Function {
8282
return fn._withTask || (fn._withTask = function () {
8383
useMacroTask = true
84-
const res = fn.apply(null, arguments)
85-
useMacroTask = false
86-
return res
84+
try {
85+
return fn.apply(null, arguments)
86+
} finally {
87+
useMacroTask = false
88+
}
8789
})
8890
}
8991

0 commit comments

Comments
 (0)