Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Infinite loop on uncaught error when using createLocalVue() #1768

Copy link
Copy link
Closed
@fearhq

Description

@fearhq
Issue body actions

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 console
I have tested this with version 1.1.2

Steps to reproduce

  • Create a component with an uncaught error
  • Mount the component using a distinct local vue in beforeEach (createLocalVue)
  • Have more than one test

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:

  console.error node_modules/vue/dist/vue.runtime.common.dev.js:621
    [Vue warn]: Error in config.errorHandler: "RangeError: Maximum call stack size exceeded"

  console.error node_modules/vue/dist/vue.runtime.common.dev.js:1884
    RangeError: Maximum call stack size exceeded
        at Array.push (<anonymous>)
        at getParent (...\node_modules\@vue\test-utils\dist\vue-test-utils.js:2799:17)
        at findAllParentInstances (...\node_modules\@vue\test-utils\dist\vue-test-utils.js:2805:3)
        at errorHandler (...\node_modules\@vue\test-utils\dist\vue-test-utils.js:2912:32)
        at ...\node_modules\@vue\test-utils\dist\vue-test-utils.js:2929:5
        at Array.forEach (<anonymous>)
        at errorHandler (...\node_modules\@vue\test-utils\dist\vue-test-utils.js:2928:26)
        at ...\node_modules\@vue\test-utils\dist\vue-test-utils.js:2929:5
        at Array.forEach (<anonymous>)
        at errorHandler (...\node_modules\@vue\test-utils\dist\vue-test-utils.js:2928:26)
        at ...\node_modules\@vue\test-utils\dist\vue-test-utils.js:2929:5
       (...)

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:

createLocalVue({ errorHandler: () => {}})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.