-
Notifications
You must be signed in to change notification settings - Fork 668
Infinite loop on uncaught error when using createLocalVue() #1768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Can you post a snippet show exactly how to reproduce this? |
Here is a minimal reproduction repository, based on Vue CLI and Reproduction repositoryhttps://github.com/antoinerey/repro-issue-vue-test-utils-1768 Steps to reproduce
OutputHere is what you should see in your console.
|
A few more information:
|
Good detective work. Would you like to make a PR to fix this? |
Sure! I've tried to pinpoint the exact root cause by reading the repository, but could not find it. I'll try again by cloning and running some tests in local, I'll get back to you. 👍 |
I've progressed a little bit, and here is the recap of what I found so far.
When running the first test case, both config.errorHandler // undefined
Vue.config.errorHandler // null However, when running the second test (which should run in complete isolation from the first one), we do not get the same values: config.errorHandler // undefined
Vue.config.errorHandler // [Function: errorHandler] This makes me think that the global Vue object is not completely reset between every test cases, and thus tests are polluted by previous ones. So I've been investigating in this direction, and could not find the root cause yet. But I'm still working on it, hopefully I'll made progress. 🤞 Also note that updating - instance.config.errorHandler = config.errorHandler || Vue.config.errorHandler
+ instance.config.errorHandler = config.errorHandler |
Hmmm I think you are right about the problem relating to polluting the global Vue instance. I am not sure if that fix is ideal or not, but if all the tests pass it's probably okay 🤔 we need to assume our test suite covers all our bases. |
Subject of the issue
There is an infinite loop in the vue-test-utils error handler when using
createLocalVue
more than once. Everything works correctly for the first test, but subsequent tests that use their own local vue instance will cause massive noise in the consoleI have tested this with version 1.1.2
Steps to reproduce
Expected behaviour
Each test should run, and produce only the errors triggered by the code
Actual behaviour
You should see an error similar to this in the console:
Possible Solution
After debugging the code, it is apparent that the first call to createLocalVue() does not have an errorHandler set. Subsequent calls, however, have their error handler set to the one in vue-test-utils. Whenever the child component has an uncaught error, it will call the vue-test-utils handler, which will call the parent's (our local vue) handler. Since it is the same handler, with the same arguments, there is infinite recursion
There are many possible solutions, but a workaround is to simply pass an empty errorHandler function:
The text was updated successfully, but these errors were encountered: