You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Simply opening and running the sandbox should show the error. Instead of getting an alert that App.vue caught the error in HelloWorld's watcher, the error escapes all the way to the top level. To see the expected behavior, open Hello World and set the watcher to immediate: false. Then hit the button to trigger the watcher. In this case the error is caught by the parent, App.vue. In the immediate case, this does not happen.
What is expected?
Errors in immediate watchers should be caught by the parent component(s)'s errorCaptured().
What is actually happening?
The error escapes to the nextTick hander. This handler has no ctx or vm to pass to the errorHandler. When errorHandler does not receive a vm, it cannot call the parent errorCaptured handlers.
This appears to be an oversight in src/core/instance/state.js. In the case options.immediate is true, cb.call(vm, watcher.value) should be wrapped in a try catch that explicitly calls handleError with the vm.
A proposed fix:
if (options.immediate) {
try {
cb.call(vm, watcher.value)
} catch (e) {
handleError(e, vm, `immediate call for watcher ${watcher.expression}`)
}
}
The text was updated successfully, but these errors were encountered:
Version
2.5.16
Reproduction link
https://codesandbox.io/s/wkpy6x5r25
Steps to reproduce
Simply opening and running the sandbox should show the error. Instead of getting an alert that App.vue caught the error in HelloWorld's watcher, the error escapes all the way to the top level. To see the expected behavior, open Hello World and set the watcher to immediate: false. Then hit the button to trigger the watcher. In this case the error is caught by the parent, App.vue. In the immediate case, this does not happen.
What is expected?
Errors in immediate watchers should be caught by the parent component(s)'s errorCaptured().
What is actually happening?
The error escapes to the nextTick hander. This handler has no ctx or vm to pass to the errorHandler. When errorHandler does not receive a vm, it cannot call the parent errorCaptured handlers.
This appears to be an oversight in src/core/instance/state.js. In the case options.immediate is true, cb.call(vm, watcher.value) should be wrapped in a try catch that explicitly calls handleError with the vm.
A proposed fix:
The text was updated successfully, but these errors were encountered: