Skip to content
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

throwing in mount causes template refs to malfunction #7020

Open
xanf opened this issue Nov 3, 2022 · 3 comments
Open

throwing in mount causes template refs to malfunction #7020

xanf opened this issue Nov 3, 2022 · 3 comments
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed.

Comments

@xanf
Copy link
Contributor

xanf commented Nov 3, 2022

Vue version

3.2.41

Link to minimal reproduction

https://stackblitz.com/edit/js-bhm79m?file=index.js

Steps to reproduce

Run an example, observe console.logs

What is expected?

testRef.value should not be null and should point to component inside#app2

What is actually happening?

testRef.value is pointing to component inside #app1 (first mount point)
or (if you had HMR) it will be null 💣

System Info

No response

Any additional comments?

if we add errorHandler to app1 via app1.config.errorHandler - error goes away

xanf added a commit to vuejs/test-utils that referenced this issue Nov 3, 2022
@LinusBorg LinusBorg added the need more info Further information is requested label Nov 4, 2022
@xanf
Copy link
Contributor Author

xanf commented Nov 4, 2022

@LinusBorg you've tagged this one as "need more info". Indeed, my initial description was a bit wrong (that's because behavior is different when HMR takes place), I've updated reproduction and issue description with more precise information

thank you!

@LinusBorg
Copy link
Member

Thanks. I now realize I forgot to hit the "Comment" button after setting that label. The comment would have read:

Works fine for me:

image

Your clarifications help, thanks. Seems weird 😅

@LinusBorg LinusBorg removed the need more info Further information is requested label Nov 4, 2022
cexbrayat pushed a commit to vuejs/test-utils that referenced this issue Nov 13, 2022
@zhangzhonghe
Copy link
Member

I think this is because some variable values are shared between different apps, and if the first-mounted app throws an error it may cause some variables not to be reset, which in turn causes the later-mounted app to behave in a way that is not expected.

For example, in the following code, since the mounted hook is called in flushPostFlushCbs, if it throws an error then the rest of the code will not be executed.

flushPostFlushCbs(seen)
isFlushing = false
currentFlushPromise = null
// some postFlushCb queued jobs!
// keep flushing until it drains.
if (queue.length || pendingPostFlushCbs.length) {
flushJobs(seen)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍰 p2-nice-to-have Priority 2: this is not breaking anything but nice to have it addressed.
Projects
None yet
Development

No branches or pull requests

3 participants