useStore after await causes Cross-Request State Pollution #2077
-
Hi! Im building an app with SSR using Vue3 and Pinia. I noticed a bug where state between users/requests leaked between each other if request was sent at the same time. It was caused by writing useStore after an await in one of my pinia action that was running on the server side, like this:
But i later fixed the issue by moving the useUserStore above the await line like this:
My questions is:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Apperently it is mentioned here in the documentation: "Since actions can be asynchronous, make sure all of your useStore() calls appear before any await. Otherwise, this could lead to using the wrong pinia instance in SSR apps" |
Beta Was this translation helpful? Give feedback.
Apperently it is mentioned here in the documentation:
https://pinia.vuejs.org/cookbook/composing-stores.html#shared-actions
"Since actions can be asynchronous, make sure all of your useStore() calls appear before any await. Otherwise, this could lead to using the wrong pinia instance in SSR apps"