vuejs / vuex

🗃️ Centralized State Management for Vue.js.
https://vuex.vuejs.org
MIT License
28.42k stars 9.57k forks source link

An error occurred in hook getInspectorState registered #2139

Open steavengong opened 2 years ago

steavengong commented 2 years ago

Version

4.0.2

Reproduction link

codesandbox.io/s/feii09

Steps to reproduce

  1. vue create project-name with vuex
  2. run
  3. open with chrome
  4. update src/store/index.js add test module (namespaced: true)
  5. first time will be all right
  6. remove test module from store
  7. refresh chrome
    tell me: backend.js:710 An error occurred in hook getInspectorState registered by plugin org.vuejs.vuex backend.js:711 Error: Missing module "test" for path "test/"
  8. refresh chrome with clear cache also tell me that error
  9. console store this attribute _makeLocalGettersCache also with test/ .....

What is expected?

can clear _makeLocalGettersCache when new project run open in the web tab

What is actually happening?

An error occurred in hook getInspectorState registered by plugin org.vuejs.vuex Error: Missing module "test" for path "test/"

but I haved remove test module
it also tell me this message

image

image

image

image

nicklasisraelsson commented 2 years ago

I got this error too and I think I figured out why it happened.

I was using the vue devtools and was looking at the vuex state for the module in the devtools. Then I removed the vuex module and started getting this error.

It seems like the dev tools caches what module is selected and when that module is not available you get this error.

The workaround for me was to select another module in the vuex state inspector in vue devtools.

Stefanosapk commented 1 year ago

I am having same issue when I dynamically import a module to a component, docs.

Example: Admin.vue

import AdminModule from '@/store/modules/admin.js';
export default { 
    mounted() {
        this.$store.registerModule('admin', AdminModule);
    },
    beforeDestroy() {
        this.$store.unregisterModule('admin');
    },
}

And what @nicklasisraelsson suggests, works for me as well as a fix. However this is a bit annoying because it outputs errors when you try to debug stuff from this async module and I have always to select another module before change page.