From 46231180fc0298a8e7bc0f6609c333a666a2bcb1 Mon Sep 17 00:00:00 2001 From: Mitar Date: Tue, 20 Nov 2018 01:32:48 -0800 Subject: [PATCH 1/2] Make sure global state is restored in the case of an exception. --- src/core/util/next-tick.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/core/util/next-tick.js b/src/core/util/next-tick.js index 07a9e841843..79ab32384c7 100644 --- a/src/core/util/next-tick.js +++ b/src/core/util/next-tick.js @@ -81,9 +81,12 @@ 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 + } }) } From 08806315ebc85f2ad2c08bbce19ae82340f391dd Mon Sep 17 00:00:00 2001 From: Evan You Date: Sat, 1 Dec 2018 00:06:48 -0500 Subject: [PATCH 2/2] Update next-tick.js --- src/core/util/next-tick.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/util/next-tick.js b/src/core/util/next-tick.js index 79ab32384c7..cc066ed86f6 100644 --- a/src/core/util/next-tick.js +++ b/src/core/util/next-tick.js @@ -83,8 +83,7 @@ export function withMacroTask (fn: Function): Function { useMacroTask = true try { return fn.apply(null, arguments) - } - finally { + } finally { useMacroTask = false } })