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
importVuefrom'vue/dist/vue.common.js'test('errorHandler should capture promise rejections in watchers',()=>{document.body.innerHTML='<div id="#app"></div>'Vue.config.errorHandler=(err)=>{console.log(err.toString())}newVue({template: `<div />`,data: ()=>({foo: false,bar: false}),mounted(){this.foo=truethis.bar=true},watch: {foo: async()=>{thrownewError('foo')},bar: ()=>{thrownewError('bar')},},}).$mount(document.body.querySelector('#app'))})
Results in the following:
(node:67048) UnhandledPromiseRejectionWarning: Error: foo
(node:67048) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:67048) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
PASS ./test.js
✓ errorHandler should capture promise rejections in watchers (19 ms)
console.log
Error: bar
at _vueCommon.default.config.errorHandler (test.js:7:13)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 1.806 s
Ran all test suites.
✨ Done in 2.71s.
So you can see that it correctly captured the bar watcher's error, but not the promise rejection in foo.
What is expected?
Errors in async watchers can be caught by Vue.config.errorHandler.
What is actually happening?
Promise rejections inside async watchers are not caught by the errorHandler.
I've tested it in Vue 3, and there app.config.errorHandler captures all promise rejections as expected.
The text was updated successfully, but these errors were encountered:
Version
2.6.11
Reproduction link
https://github.com/vvanpo/minimal-repros/tree/master/vue2
Steps to reproduce
Finding the same problem as posted here: #11035
See the minimal repro:
Results in the following:
So you can see that it correctly captured the
bar
watcher's error, but not the promise rejection infoo
.What is expected?
Errors in async watchers can be caught by
Vue.config.errorHandler
.What is actually happening?
Promise rejections inside async watchers are not caught by the
errorHandler
.I've tested it in Vue 3, and there
app.config.errorHandler
captures all promise rejections as expected.The text was updated successfully, but these errors were encountered: