From b111de486b1bdc747fe0f5795fe22697d151bb8c Mon Sep 17 00:00:00 2001 From: Mitar Date: Fri, 30 Nov 2018 21:07:46 -0800 Subject: [PATCH] fix: make sure global state is restored in the case of an exception in macrotask callback (#9093) --- src/core/util/next-tick.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/util/next-tick.js b/src/core/util/next-tick.js index 07a9e84184..cc066ed86f 100644 --- a/src/core/util/next-tick.js +++ b/src/core/util/next-tick.js @@ -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 + } }) }