kriszyp / lmdb-js

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

Weird overlappingsync issue #165

Closed kylebernhardy closed 2 years ago

kylebernhardy commented 2 years ago

LMDB.js 2.3.8 Ubuntu 20.04

I am running into issues in my tests when interacting with empty environments. This code throws an error:

'use strict';

const lmdb = require('lmdb');
const fs = require("fs");

(async()=> {
    try {
        fs.rmSync('./data', {recursive: true});
    }catch (e) {};
    let env_init = {
        "path": './data',
        overlappingSync: true
    };
    let env = lmdb.open(env_init);
    let dbi = env.openDB('test', {
        dupSort: false,
        sharedStructuresKey: Symbol.for('structures')
    });
    await env.close();
})()

Error:

/home/kyle/code/lmdb-test/node_modules/lmdb/dist/index.cjs:482
                                        env.sync(() => {
                                            ^

TypeError: env.sync is not a function
    at /home/kyle/code/lmdb-test/node_modules/lmdb/dist/index.cjs:482:10
    at new Promise (<anonymous>)
    at /home/kyle/code/lmdb-test/node_modules/lmdb/dist/index.cjs:481:16

Setting overlappingsync to false does not thro an error:

'use strict';

const lmdb = require('lmdb');
const fs = require("fs");

(async()=> {
    try {
        fs.rmSync('./data', {recursive: true});
    }catch (e) {};
    let env_init = {
        "path": './data',
        overlappingSync: false
    };
    let env = lmdb.open(env_init);
    let dbi = env.openDB('test', {
        dupSort: false,
        sharedStructuresKey: Symbol.for('structures')
    });
    await env.close();
})()
kriszyp commented 2 years ago

Published a fix in v2.3.9

kylebernhardy commented 2 years ago

As always, thank you for the quick turnaround. This works perfect.