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

Internal Vue crash: v-if on component #910

Closed
jods4 opened this issue Apr 2, 2020 · 7 comments
Closed

Internal Vue crash: v-if on component #910

jods4 opened this issue Apr 2, 2020 · 7 comments
Labels
🐞 bug Something isn't working

Comments

@jods4
Copy link
Contributor

jods4 commented Apr 2, 2020

Version

3.0.0-alpha.10

Reproduction link

https://jsfiddle.net/3d2twLq9/1/

Steps to reproduce

Open the console, click on the button. Vue does some bad stuff.

What is expected?

v-if is replaced by v-else, no error

What is actually happening?

Stuff crashes, apparently because slot content is evaluated before v-if, which results in null dereferences and then bad stuff.


This minimal repro stays usable after the crash (you could set a new some value and recover).
My own app is more complex and is unusable after this bug.

@jods4
Copy link
Contributor Author

jods4 commented Apr 2, 2020

Using a component here is the key difference. If you do <div v-if='some'> instead then everything works fine.

@posva posva added the 🐞 bug Something isn't working label Apr 2, 2020
@jods4
Copy link
Contributor Author

jods4 commented Apr 4, 2020

@yyx990803 The simple repro is fixed but I'm still having issues in my project.
Not sure what I can do because it's a lot more complex than a simple repro.

That said, this fragment:

<ui-form
      v-if="selected != null"
      @save="updateGroup(selected)"
    >
<!-- ... more stuff inside -->
         <input
            type="checkbox"
            :value="right.name"
            v-model="selected.roles"
            style="margin-right: 12px;"
          />

Still executes code with selected equals to null.
image

Exception is caught and if I let it run it then fails with a stack overflow:
image

Any idea?

@yyx990803
Copy link
Member

Well... can't really tell anything without a repro. If you can maybe extract part of your project into something runnable, I can take a look.

@jods4
Copy link
Contributor Author

jods4 commented Apr 4, 2020

I'll try to see if I can come up with another repro... really not sure which bits are responsible for the problem after alpha.11

@jods4
Copy link
Contributor Author

jods4 commented Apr 4, 2020

@yyx990803 I was working on other stuff and the bug went away with an unrelated change.
I have even less idea now what happened. It seems wrong that a null selected was accessed inside a slot that was under a v-if=selected but I can't reproduce it anymore.

Also can't exclude I was doing something stupid.

Should it pop up again I'll try to find a repro but I'm giving up for now.

@jods4
Copy link
Contributor Author

jods4 commented Apr 13, 2020

@yyx990803 Got it.
It was hard but I managed to nail down a small repro.
https://jsfiddle.net/e635agws/15/
Click on the button with the dev tools open, you'll see that some.name is evaluated with some being null, even though that binding is inside a v-if="some".

yyx990803 added a commit that referenced this issue Apr 14, 2020
This fixes the case where a child component is added to the queue before
its parent, but should be invalidated by its parent's update. Same logic
was present in Vue 2.

Properly fixes #910
ref: #910 (comment)
@yyx990803
Copy link
Member

78977c3

yyx990803 added a commit that referenced this issue May 28, 2021
fix #3099

Also changes the original fix for #910 by moving the fix from
reactivity to the scheduler
@github-actions github-actions bot locked and limited conversation to collaborators Nov 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐞 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants