kriszyp / lmdb-js

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

putSync returning Promise #235

Open anywhichway opened 1 year ago

anywhichway commented 1 year ago

putSync is occasionally returning a Promise rather than a regular value. A review of the source shows the below at line 709 in write.js, so unless some other core code manages to force Promise resolution before returning, I can see how this would happen.

Is this expected? In the meantime, I am avoiding the use of putSync, which is relatively inconsequential.

putSync(key, value, versionOrOptions, ifVersion) {
            if (writeTxn)
                return this.put(key, value, versionOrOptions, ifVersion);
            else
                return this.transactionSync(() =>
                    this.put(key, value, versionOrOptions, ifVersion) == SYNC_PROMISE_SUCCESS, overlappingSync? 0x10002 : 2); // non-abortable, async flush
        },
kriszyp commented 1 year ago

Good catch, thank you.

anywhichway commented 1 year ago

You are welcome. As I recall removeSync currently has a similar pattern in the write.js file.

Thanks for your prompt responses.

anywhichway commented 1 year ago

@kriszyp See repository https://github.com/anywhichway/lmdb-issues