Closed stephenjason89 closed 7 months ago
I think this might be related, @danielroe @antlionguard
https://github.com/nuxt/bridge/issues/436
The reproduction needs to have SSR:true in order to see the error
The stackblitz was not using SSR
I experience this as well https://github.com/vuejs/pinia/discussions/1513
@Lanayx for the meantime this.$nuxt helped me get around this problem
@stephenjason89 this.$nuxt is unavailable in latest pinia :( https://github.com/vuejs/pinia/discussions/1526
@stephenjason89 this.$nuxt is unavailable in latest pinia :( vuejs/pinia#1526
It's available now but not have a type support.
@stephenjason89 this.$nuxt is unavailable in latest pinia :( vuejs/pinia#1526
Use @ts-ignore because there's no type support.
@antlionguard can you please give more information - where it is availabe?
I'm using
"@pinia/nuxt": "^0.4.0",
"nuxt": "3.0.0-rc.8",
"pinia": "^2.0.18"
And this.$nuxt
is undefined inside store action on server side
Ah, I see, it was removed from Nuxt3, so Nuxt2 users are more lucky here
Let's hope it gets fixed soon π @Lanayx I'm using nuxt bridge
As far as I can understand Nuxt3 developers motivation - they want us to pass nuxtApp explicitly into actions parameters, rather than implicitly receiving it from this
@Lanayx That's correct. I hope it gets fixed soon
up please, is there any hope for this bug to be fixed ? (nuxt3 + pinia). This bug happen to me when I call async methods in pinia actions during SSR.
I struggled with this for a while, the solution for me was to instantiate the store before I called a method inside of it.
In my use case, I was trying to build Bread Crumbs aided by the current Route, my code looked like this:
export const useBreadCrumbStore = defineStore("breadcrumbs", () => {
const { currentRoute } = useRouter();
const makeBreadcrumbList = () => {
const fullPath = currentRoute.value.fullPath;
fullPath.split("/").forEach((path, index) => {
...
}
}
}
Which would error out with the Nuxt Instance Unavailable
.
What I ended up having to do, was to call the store on my page, before my useSEO
composable which actually calls the "makeBreadcumbList" function.
I found this doc on Pinia's site which clarified what was happening in my case.
https://pinia.vuejs.org/core-concepts/outside-component-usage.html
Hope this helps.
Up. Nuxt 3 + Pinia same error. But it happens not always. I can't explain how, but if i call more than 3 stores from server plugin, then in last store error happens.
Would you be able to provide a reproduction? π
This issue was closed because it was open for 7 days without a reproduction.
Environment
Darwin
v18.7.0
2.16.0-27616340.013f051b
yarn@3.2.1
webpack
buildDir
,srcDir
,bridge
,components
,ssr
,dev
,alias
,image
,generate
,head
,typescript
,publicRuntimeConfig
,privateRuntimeConfig
,css
,loading
,loadingIndicator
,plugins
,buildModules
,modules
,proxy
,axios
,vuetify
,build
,serverHandlers
,devServerHandlers
@nuxtjs/vuetify@1.12.3
,@nuxt/image@0.7.1
,@nuxtjs/axios@5.13.6
,@nuxtjs/proxy@2.1.0
,nuxt-social-meta@1.0.0
Build Modules:
()
,nuxt-storm@1.1.3
,nuxt-compress@5.0.0
,@pinia/nuxt@0.3.1
,~/modules/apolloSSR
,@nuxt/bridge@3.0.0-27639120.e7a7f9b
Reproduction
https://github.com/vuejs/pinia/discussions/1526
Describe the bug
I am getting this error
When running this pinia actions during SSR
I rolled back to the old this.$nuxt for now to temporarily solve the issue
Additional context
The page being loaded uses the default.vue layout which has an apollo query "labels"
So that, together with this query causes the error.
No response
Logs
No response