fix(vue): Avoid Render Warning Loop in Vue3 Apps #6014
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before submitting a pull request, please take a look at our
Contributing guidelines and verify:
yarn lint
) & (yarn test
)Summary of the change (@Lms24):
This PR fixes an infinite loop that would occur in Vue 3 apps with undeclared refs.
Why this happens:
ref
in the second arg ofh
method (see https://cn.vuejs.org/guide/essentials/template-refs.html)console.warn
to print the error stack.console
(for theBreadCrumbs
integration), and adds the message to theBreadcrumb
withsafeJoin
.safeJoin
converts variables to string. The ref variable is a proxied object viaProxy
by Vue. so, whenString(value)
is called upon the undefined ref, it will trigger the getter of the Proxy, and which causes Vue3 to callconsole.warn
again.Solutions:
Because there's no reliable way of testing if an object is a
Proxy
, the solution in this case is tailored to this exact scenario. In the breadcrumbs integration code, we check if the passed arguments to theconsole.warn
match the specific warning described above. In case of a match, we alter the following argument to not trigger a warning again, thus leaving us with the one warning we want and getting rid of the infinite loop.For more details, see the previous (almost identical) PR #6010
New PR because of #6010 (comment)
fixes #5916
fixes #4743