@pinia/nuxt - No Active Pinia - Advanced Implementation from another plugin #3085
Replies: 3 comments
-
|
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.
Uh oh!
There was an error while loading. Please reload this page.
-
Reproduction
https://github.com/components-web-app/cwa-nuxt-module/tree/dev
Steps to reproduce the bug
When 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
CWAclass creates a sub-class of storage where all the store definitions are created. Before they are created I've confirmed and there is an active pinia instance.When I am trying to access the stores now, I get
"getActivePinia()" was called but there was no active Pinia.Before I access the stores I use my own composable
useCwa- I've also checked in there and the pinia instance appears to be there as the object inuseNuxtAppapp response.I think this line causes all my issues...
https://github.com/vuejs/pinia/blob/v3/packages/nuxt/src/runtime/plugin.vue3.ts#L29
Expected behavior
I 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 behavior
500 errors.
Additional information
This 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.
All reactions