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
fix(nuxt): don't overwrite scope in runWithContext if scope already exists #26976
Conversation
Run & review this pull request in StackBlitz Codeflow. |
Video proof 2024-04-28.010229.1.mp4 |
It may be we need to fix the bug in another way. Can you add a regression test in this PR? |
Okie, I'll try to do that tomorrow. I still believe it could be Vue bug. Also I don't see if this could break something since unctx probably does nothing on CSR in this case, isn't it? |
Currently the Nuxt app context is set on client side, but this is not necessarily guaranteed in future.
|
Maybe I'll still add tests for this issue. Should I make separate PR for it or keep it there? |
As you like! Depending on the solution we find, we can still treat this PR as the source of truth, and update it ... |
@danielroe it's done. Test passes with my changes and doesn't pass without them. |
It seems like units have bad time due to ui templates... I can't run any tests after merge |
I looked more into the code and I agree that my solution would not be good. However, I've found the issue. It's I'm not an expert in Vue reactivity, but I can guess that this is the global scope that isn't disposed, and that's exactly the reason why watchers aren't cleared - they're not supposed to be. |
I've pushed new implementation.
|
Should be good now. Would you need me to port this to Bridge when approved? Also: if some await will appear before runWithContext in defineNuxtComponent this solution will break (without second argument). I don't know how much is that risk I'll let you decide that :) |
…nuxt#26821)" This reverts commit 468ebbd.
🔗 Linked issue
Resolves #25029
📚 Description
This issue can cause significant problems for anybody using root watch on CSR with defineNuxtComponent.
Turns out the issue is runWithContext callback for setup. I don't think that removing that completely is needed since on SSR it's a good feature if you're using asyncContext.
So I've decided to simply remove this callback on client since there context is standalone.
Fun fact: getCurrentInstance is not undefined there, so it could also possibly be upstream vue bug, but I'm not sure about it.