Skip to content

Commit

Permalink
fix: make sure global state is restored in the case of an exception i…
Browse files Browse the repository at this point in the history
…n macrotask callback (vuejs#9093)
  • Loading branch information
mitar authored and aJean committed Aug 19, 2020
1 parent 5649486 commit 3728edd
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/core/util/next-tick.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,11 @@ if (typeof Promise !== 'undefined' && isNative(Promise)) {
export function withMacroTask (fn: Function): Function {
return fn._withTask || (fn._withTask = function () {
useMacroTask = true
const res = fn.apply(null, arguments)
useMacroTask = false
return res
try {
return fn.apply(null, arguments)
} finally {
useMacroTask = false
}
})
}

Expand Down

0 comments on commit 3728edd

Please sign in to comment.