-
Notifications
You must be signed in to change notification settings - Fork 198
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: break reference to state object #336
fix: break reference to state object #336
Conversation
Thanks |
@kieusonlam This actually breaks SSR in Nuxt for me. I started getting "Mismatching childNodes vs. VNodes". After I rolled back to version v4.0.1-rc.1 it worked again. I determined this to be the root cause. |
OMG @dneckel thank you so much for this comment!! I was on I think I have seen the whole internet on the topic before finally finding your comment. |
@dneckel sorry to hear that. Would it be possible for you to setup a small codepen/repo to reproduce the issue? |
In nuxt-modules#336 the server side rendering was broken. The problem is that when assigning the apollo cache to the nuxt state, in `beforeNuxtRender` the state is actually still empty. It only works because a reference is assigned there, which is later populated. In nuxt-modules#336 another problem was fixed: Before this fix everything which was populated in the cache before `beforeNuxtRender` was cleared. To fix both issues I propose to remove the workaround introduced in nuxt-modules#274 for the case when the `cache` object is shared across requests. Since the server is handling requests in parallel, its simply impossible to have a shared cache instance. Users of `nuxtjs/apollo` need to make sure that the cache instance is not shared, there is no other way. That's why I propose to delete this workaround code, to fix all issues at the same time. Issue: nuxt-modules#352
@DiskoPete You can reproduce the issue by calling http://localhost:3000/normalQuery when running the normal fixture ( A proposal to fix it is here: #362 |
This is still broken. Any updates on when it will be fixed? |
I just rolled back to 4.0.1-rc.1 and I still have this issue! |
I found and issue with rehydrating the InMemoryCache.
Since the state is retrieved as a reference here: https://github.com/nuxt-community/apollo-module/blob/master/lib/templates/plugin.js#L121
it is cleared with a call to
reset
there: https://github.com/nuxt-community/apollo-module/blob/master/lib/templates/plugin.js#L129Thus also clearing the previously stored states on the
nuxtState
object.I broke the reference by iterating the states and calling
Object.assign
on each of them, while assigning it back to thenuxtState.apollo
object.