kriszyp / lmdb-js

Simple, efficient, ultra-fast, scalable data store wrapper for LMDB
Other
520 stars 44 forks source link

TypeError: Cannot read properties of undefined (reading 'then') in return writeTxn.childResults.then(...) #265

Open dskvr opened 1 year ago

dskvr commented 1 year ago

I have a crawler that leverages lmdb-js and it periodically hits an error.

Error:

07:17:19.848 [ERROR crawler] error crawling [redacted] Cannot read properties of null (reading 'childResults')
07:17:19.848 [ERROR crawler] error crawling [redacted] Cannot read properties of null (reading 'childResults')
07:17:19.848 [ERROR crawler] error crawling [redacted] Cannot read properties of null (reading 'childResults')
07:17:20.189 [ERROR crawler] error crawling [redacted] Cannot read properties of undefined (reading 'then')
07:17:20.190 [ERROR crawler] error crawling [redacted] Cannot read properties of null (reading 'childResults')
file:///[redacted]/node_modules/lmdb/write.js:741
                                                        return writeTxn.childResults.then(() => finishTxn(result));

Browsing through the source, I cannot think of a reason this would be happening.

Any ideas what would cause this?

kriszyp commented 1 year ago

I am also not sure what would lead to this condition, but I would guess that it may be due to using nested transactions that with asynchronously callback execution that are allowed to overlap (not awaiting the result of one before the next starts or finishes). Certainly if you are able to figure out more specifically how to reproduce, I can try to address it.