store._customProperties is undefined
Extension version : 2.1.1 Vue.js devtools version : 7.7.7 Pinia version : 2.3.0 Vue version : 3.5.13
When using the Vue Devtools, stores are accessible through the "Pinia (root)" section at the top of the stores panel. However, clicking on any store name listed under “Pinia (root)” triggers an error in the console:
Unhandled promise rejection: TypeError: can't access property "size", store._customProperties is undefined
And when the page initially loads, the following error is (sometimes) logged :
Unhandled promise rejection: TypeError: can't access property "forEach", store._customProperties is undefined
Note : All my app stores are created with the object syntax of defineStore().
In dev mode, store._customProperties exists as a Set, but in the built version it’s undefined.
This may be related to the build process (minification or internal Pinia props not being preserved).
Here is what I found as a workaround in my project :
Adding a small Pinia plugin that ensures _customProperties is always defined completely resolves the issue:
// main.ts
import { createPinia } from 'pinia'
const pinia = createPinia()
pinia.use(({ store }) => {
if (store && !('_customProperties' in store)) {
store._customProperties = new Set()
}
})
app.use(pinia)