@pinia/nuxt - No Active Pinia - Advanced Implementation from another plugin #3085
-
Reproductionhttps://github.com/components-web-app/cwa-nuxt-module/tree/dev Steps to reproduce the bugWhen running my application I have a module, it adds plugin and it creates many stores that are needed. https://github.com/components-web-app/cwa-nuxt-module/blob/dev/src/runtime/plugin.ts It was all working fine until recent updates either within Nuxt or this module. The When I am trying to access the stores now, I get Before I access the stores I use my own composable I think this line causes all my issues... https://github.com/vuejs/pinia/blob/v3/packages/nuxt/src/runtime/plugin.vue3.ts#L29 Expected behaviorI should be able to access my stored after the app is rendered, or the hook is called at the wrong time or... something horrendous is happening as a side-effect for me here. Thoughts? Actual behavior500 errors. Additional informationThis is a discussion point to address with questions, I'm happy to work on things my side, I just want to understand the context for this change, and see if this is a Pinia bug from my edge use case, or something which I need to work out a new implementation of. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
|
I can confirm that the issue for me has bagun in 0.11.3 - 0.11.2 is fine. |
Beta Was this translation helpful? Give feedback.
-
|
My guess is that you are calling a Your reproduction is a whole project so it's hard for me to take a look. If you can boil it down to just nuxt + pinia and no other modules, I can take a look. Also please, no docker |
Beta Was this translation helpful? Give feedback.
-
|
Understood for the reproduction. I'll work on it. I do however feel it is a bug due to a minor patch release causing a breaking change. I trace the calls and it's because I then make calls after the render and now with the 'clean up' code in the rendered hook, there is no more pinia store. However there had been an active store and I am sure that I have been calling the I actually use But certainly the clean up is then removing the active pinia from context so when I call the callback later on from my I do realise that I could and should create a more minimal reproduction, but instead of just creating a PR which fixes it by un-doing the call you've added in here: https://github.com/vuejs/pinia/blob/v3/packages/nuxt/src/runtime/plugin.vue3.ts#L29 - it'd be good to understand the context and reasoning that put this line of code there and how it wouldn't cause issues trying to use a store after the app has already rendered. |
Beta Was this translation helpful? Give feedback.
See #2915, you can always getActivePinia() in a different hook, save it, and then set it again after pinia nuxt but you will suffer from the same problem as #2915