|
|
@@ -4,25 +4,33 @@ import config from '../config'
|
|
|
import { warn } from './debug'
|
|
|
import { inBrowser, inWeex } from './env'
|
|
|
import { isPromise } from 'shared/util'
|
|
|
+import { pushTarget, popTarget } from '../observer/dep'
|
|
|
|
|
|
export function handleError (err: Error, vm: any, info: string) {
|
|
|
- if (vm) {
|
|
|
- let cur = vm
|
|
|
- while ((cur = cur.$parent)) {
|
|
|
- const hooks = cur.$options.errorCaptured
|
|
|
- if (hooks) {
|
|
|
- for (let i = 0; i < hooks.length; i++) {
|
|
|
- try {
|
|
|
- const capture = hooks[i].call(cur, err, vm, info) === false
|
|
|
- if (capture) return
|
|
|
- } catch (e) {
|
|
|
- globalHandleError(e, cur, 'errorCaptured hook')
|
|
|
+ // Deactivate deps tracking while processing error handler to avoid possible infinite rendering.
|
|
|
+ // See: https://github.com/vuejs/vuex/issues/1505
|
|
|
+ pushTarget()
|
|
|
+ try {
|
|
|
+ if (vm) {
|
|
|
+ let cur = vm
|
|
|
+ while ((cur = cur.$parent)) {
|
|
|
+ const hooks = cur.$options.errorCaptured
|
|
|
+ if (hooks) {
|
|
|
+ for (let i = 0; i < hooks.length; i++) {
|
|
|
+ try {
|
|
|
+ const capture = hooks[i].call(cur, err, vm, info) === false
|
|
|
+ if (capture) return
|
|
|
+ } catch (e) {
|
|
|
+ globalHandleError(e, cur, 'errorCaptured hook')
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ globalHandleError(err, vm, info)
|
|
|
+ } finally {
|
|
|
+ popTarget()
|
|
|
}
|
|
|
- globalHandleError(err, vm, info)
|
|
|
}
|
|
|
|
|
|
export function invokeWithErrorHandling (
|