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

Caching getters on server with Nuxt2 is not working as expected #2529

Open
yoshrubin opened this issue Dec 19, 2023 · 3 comments
Open

Caching getters on server with Nuxt2 is not working as expected #2529

yoshrubin opened this issue Dec 19, 2023 · 3 comments
Labels
contribution welcome vue 2.x Specific to Vue 2 usage

Comments

@yoshrubin
Copy link

Reproduction

https://github.com/yoshrubin/pinia-ssr-bug

Steps to reproduce the bug

  1. run yarn build && yarn start

Expected behavior

To return a cached version of the getter

Actual behavior

the getter was called for each loop in the v-for loop instead of returning a cached version

Additional information

The issue is for Nuxt2 with@pinia/nuxt@0.2.1 which uses pinia@^2.1.7

@posva posva added vue 2.x Specific to Vue 2 usage contribution welcome labels Dec 20, 2023
@yoshrubin
Copy link
Author

@posva Hey thanks for adding labels, from what I can tell this appears to be an issue with nuxt-bridge as well which will be an issue for anyone trying to make the move from Nuxt2 to Nuxt3.
Happy to provide a repro for that as well if it will help narrow down the source of this issue.

@yoshrubin
Copy link
Author

it appears that the issue is here packages/pinia/src/store.ts#L179C19-L179C19 the computed is getting re-evaluated multiple times even though the dependencies aren't changing.

I did come across this discussion that I am unsure if it is relevant or not #1020 and he references

ssr: make computed inactive during ssr, fix memory leak (f4f0966), closes #5208

from the vue 3.2.27 CHANGELOG

@yoshrubin
Copy link
Author

@posva seems like the "issue" I mention here is actually the intended functionality based on responses to
vuejs/vue#10151 and nuxt/nuxt#2447.
Wish there was a better solution or more documentation for this kind of issue (maybe a mention in the SSR section of the Docs).
Happy to contribute to the docs myself when I clear some time for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution welcome vue 2.x Specific to Vue 2 usage
Projects
None yet
Development

No branches or pull requests

2 participants