vuejs / vuejs/devtools

TypeError: this.refEditor.get(...) is undefined. Editing Pinia state on component causes error.

Open
#906 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.9k
Forks
279
PR merge metrics
No merged PRs in 30d

Description

Environment

  • OS: Windows
  • NPM: 11.4.1
  • Vue.js devtools: 7.7.7
  • vue: 3.5.16
  • pinia: 3.0.3
  • Browsers: Firefox, Chrome

Description

There is a bug pertaining to either Vue.js devtools or Pinia that is observable in devtools v7 but not v6.

Expected behavior

Typically, when a Pinia store is loaded, you can select a component on the page and see a section on the right pertaining to props, setup data, and the Pinia store. Devtools lets you edit the Pinia state from this view:

Image

Actual behavior

When trying to edit the Pinia state from this view in Firefox, an error appears reporting: TypeError: this.refEditor.get(...) is undefined:

Image

The same error happens in Chrome, but instead it shows the name of the actual state property:

Image

The reason why one of the screenshots shows an edited count is because editing Pinia state from the Pinia tab instead of the Components tab results in the expected behavior where there is no issue editing the Pinia state.

Reproduction steps

Fortunately this is easy to reproduce:

  • Create a new project with npm create vue@latest
  • Add Pinia to the project
    • This will add a counter.js store by default
  • In src/components/HelloWorld.vue, optionally add the following to show the count on the page:
    <script setup>
      import { useCounterStore } from '../stores/counter'
      const counterStore = useCounterStore()
      ...
    </script>
    
    ...
    <div class="greetings">
      <p style="font-size: 4em"> The count: {{ counterStore.count }}</p>
    ...
    
  • Run npm install and npm run dev
  • Visit the site and try editing the Pinia store, such as by incrementing/decrementing the count state, from both the Pinia tab, which should be successful, and from the HelloWorld component in the Components tab, which should result in the error.

More Details

The browser is saying the error happens in prepare.js. Here is the prettified version of the place where the error happens:

Image

I could be wrong, but after doing some investigating, I strongly suspect this is referring to https://github.com/vuejs/devtools/blob/07a637aa7fc70062d586bacd2176e6a65d449a10/packages/devtools-kit/src/core/component/state/editor.ts#L33

Thank you very much for any assistance.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the Vue starter project and Pinia, comparing edits from the Pinia tab with edits in the Components tab. Then inspect packages/devtools-kit/src/core/component/state/editor.ts around the suspected refEditor lookup. Done means editing Pinia state from the Components tab works in both Firefox and Chrome without the TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.