Skip to content

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'forEach') caused by mixing of dev and prod code pinia #845

Open
@einavk

Description

@einavk

Hi,

I'm using a microfrontend architecture, where each MF has its own pinia. Pinia is created and destroyed properly per each application.

Mostly, the code for the stores is completely unrelated.
However, there are few cases where we are sharing specific store code (such as "notification store", which is same for all apps).
The shared store code is used via a library, that has its own versioning, is installed via yarn, and is production build.
When running the application in dev mode (using webpack and webpack dev server) when dev tools is disabled, all is good.
When enabling devtools, suddenly errors appear, a common one being:

pinia.mjs:803 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'forEach')
at pinia.mjs:803:1
at bt (prepare.js:1:63085)
at prepare.js:1:68771
at prepare.js:1:33623
at prepare.js:1:33615

After a while, trying to figure out what causes this issue, I noticed that when I install the shared code package in development build, these errors are gone, which led me to the conclusion that mixed production-dev builds of store code are causing issues in dev tools.
I understand that development build is needed in order to explore the pinia stores on devtools, but I think in such a case, the "production" stores should just not be visible for exploration in the devtools, instead of causing exceptions.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions