3.1.1
https://codesandbox.io/s/vue-template-2tpsf
For an exception to be thrown.
An exception is not thrown, instead a console.error is logged, and only if we're not running in production. If we're running in production, literally nothing happens:
if (process.env.NODE_ENV !== 'production') {
console.error(("[vuex] unknown mutation type: " type));
}
In the sandbox link above, you can see there is no exception is caught because AN ERROR WAS CAUGHT! should appear in the console log, but it doesn't, per:
try {
commit("fo/bar");
} catch (e) {
console.error("AN ERROR WAS CAUGHT!", e);
}
Our error handling code cannot function correctly if no exception is thrown (as it should be, in this case).
This check is meant to be notice the developers that there is a mistake on their code (which is assertion) and only available in development env. Also we strip out it on production env to reduce the file size.
You should not rely on the behavior when you implement your app logic.
Can this issue be reopened? It's causing serious problems for us. Sometimes the error happens for some users, and sometimes it doesn't. Without being able to catch this there is no way for us to handle this (EDIT: without manually checking store._mutations, which I assume is internal API that shouldn't be touched, but this hack is what we're forced to resort to...)
I also think this should throw an error.
The console message could be easily missed during development, and if code goes to production it will fail silently, making it very hard to debug issues.
Is there ever a valid case for having a dispatch or commit refer to an action that doesn't exist? Otherwise, why not throw an error??