Skip to content

Conversation

@skirtles-code
Copy link
Contributor

Calling defineStore without an id appears to succeed, but it fails when calling useStore:

Cannot read properties of undefined (reading 'startsWith')
    at devtoolsPlugin (pinia.mjs:925:19)
    at pinia.mjs:1631:48
    at EffectScope.run (reactivity.esm-bundler.js:37:24)
    at pinia.mjs:1631:38
    at Array.forEach (<anonymous>)
    at createSetupStore (pinia.mjs:1628:14)
    at createOptionsStore (pinia.mjs:1223:13)
    at useStore (pinia.mjs:1705:17)

The undefined id causes various other problems, but this just happens to be the first line that throws an error.

I've encountered this a few times on Vue Land, so I thought it might be better to have an explicit error in dev that explains what the problem is.

@netlify
Copy link

netlify bot commented Apr 24, 2023

Deploy Preview for pinia-official canceled.

Name Link
🔨 Latest commit c6131cf
🔍 Latest deploy log https://app.netlify.com/sites/pinia-official/deploys/644636eb713b1a00086c7309

@codecov-commenter
Copy link

Codecov Report

Merging #2167 (edb8385) into v2 (1d27718) will decrease coverage by 0.18%.
The diff coverage is 0.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##               v2    #2167      +/-   ##
==========================================
- Coverage   94.69%   94.51%   -0.18%     
==========================================
  Files          12       12              
  Lines        3242     3248       +6     
  Branches      219      219              
==========================================
  Hits         3070     3070              
- Misses        168      174       +6     
  Partials        4        4              
Impacted Files Coverage Δ
packages/pinia/src/store.ts 84.07% <0.00%> (-0.53%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Member

@posva posva left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks 🙌

@posva posva changed the title dx: throw an error if store id is missing feat(dx): throw an error if store id is missing Apr 24, 2023
@posva posva merged commit b74eb4f into vuejs:v2 Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants