Skip to content

Commit d33bd37

Browse files
authored
Improve error message
1 parent e1419d7 commit d33bd37

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/pinia/src/rootStore.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,12 @@ interface _SetActivePinia {
4343
* Get the currently active pinia if there is any.
4444
*/
4545
export const getActivePinia = () =>
46-
(hasInjectionContext() && inject(piniaSymbol)) || (import.meta.server ? throw new Error("Cannot get active pinia as it does not find context") : activePinia)
47-
46+
(hasInjectionContext() && inject(piniaSymbol)) ||
47+
(import.meta.server
48+
? throw new Error(
49+
'Pinia instance not found in context and cannot fall back to global activePinia on server - this would lead to shared state between requests'
50+
)
51+
: activePinia)
4852
/**
4953
* Every application must own its own pinia to be able to create stores
5054
*/

0 commit comments

Comments
 (0)