Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: Cannot read properties of undefined (reading 'data') #131

Open
erikbjoern opened this issue Aug 11, 2022 · 0 comments
Open

Comments

@erikbjoern
Copy link

Describe the bug

Uncaught error at src/connection/Connection.ts:45 in the source code:

vuex-orm.esm-bundler.js:2298 Uncaught TypeError: Cannot read properties of undefined (reading 'data')
    at Connection.get (vuex-orm.esm-bundler.js:2298:62)
    at eval (eval at cashRows (cash.ts:1:1), <anonymous>:1:53)
    at cashRows (cash.ts:504:5)
    at wrappedGetter (vuex.esm.js:881:12)
    at Vue.<anonymous> (vuex.esm.js:140:12)
    at Watcher2.get (vue.runtime.esm.js:4473:25)
    at Watcher2.evaluate (vue.runtime.esm.js:4578:21)
    at Vue.computedGetter [as cash/cashRows] (vue.runtime.esm.js:4830:17)
    at Object.get [as cash/cashRows] (vuex.esm.js:671:39)
    at VueComponent.mappedGetter (vuex.esm.js:1026:26)

It's calling return this.database.store.state[connection][entity].data in src/connection/Connection.ts:45.

We currently have five models in VuexORM and at the point in time where this method was called, only four of them existed on state[connection] - I know that at least one of them had data stored in it at the time, and I'm almost sure the other three had too, since they are populated from network requests that load initial state. But the cashRow model is only used in frontend, and it wasn't populated with any data yet.

Steps to reproduce the bug

I cannot even reproduce it myself anymore. I suspected that the problem was caused by a Vue.$watch called from within a created hook (options API), but I'm not sure. It was not set to { immediate: true } either. It is watching a vuex getter which returns store.$repo(models.cashRow).all()

Expected behaviour

I expected this.$repo(model).all() to always be callable and return an empty array if no data is found

Versions

  • "@vuex-orm/core": "^1.0.0-draft.16"
  • "vue": "2.6.10"
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

No branches or pull requests

1 participant