You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am running into the following error when trying to import my models in my Node.js (node v20.10.0) application: #1337
/node_modules/@nozbe/watermelondb/decorators/lazy/index.js:16
configurable: configurable,
^
TypeError: Cannot destructure property 'configurable' of 'descriptor' as it is undefined.
at lazy (/node_modules/@nozbe/watermelondb/decorators/lazy/index.js:16:19)
I was able to get a workaround by changing how I set up my @lazy methods in my models:
Note the removal of the @lazy decorator. If I kept it, then my application would give this error when these queries are eventually called with .fetch(), e.g. await post.commenters.fetch():
WARN Possible Unhandled Promise Rejection (id: 0):
TypeError: Cannot read property 'fetch' of undefined
Since TypeScript/JavaScript getters are already lazily evaluated, I think this should be OK. I'm not too familiar with the internals of the decorators here, but I wanted to start a discussion and see if there are any concerns with doing this, or if there is an alternative workaround to either of the above issues.
Looking at the code, my understanding it that it would hinder performance a bit, as each subsequent call is evaluated lazily instead of using the precomputed value. Is that it?
The text was updated successfully, but these errors were encountered:
garygcchiu
changed the title
Different between using @lazy decorator vs getter?
Different between using @lazy decorator vs getter?
Jan 18, 2024
Hey,
I am running into the following error when trying to import my models in my Node.js (
node v20.10.0
) application: #1337I was able to get a workaround by changing how I set up my
@lazy
methods in my models:Instead of:
Do:
Note the removal of the
@lazy
decorator. If I kept it, then my application would give this error when these queries are eventually called with.fetch()
, e.g.await post.commenters.fetch()
:Since TypeScript/JavaScript getters are already lazily evaluated, I think this should be OK. I'm not too familiar with the internals of the decorators here, but I wanted to start a discussion and see if there are any concerns with doing this, or if there is an alternative workaround to either of the above issues.
Looking at the code, my understanding it that it would hinder performance a bit, as each subsequent call is evaluated lazily instead of using the precomputed value. Is that it?
The text was updated successfully, but these errors were encountered: