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

Problems using lmdb-js with bun #259

Open
larsw opened this issue Oct 25, 2023 · 2 comments
Open

Problems using lmdb-js with bun #259

larsw opened this issue Oct 25, 2023 · 2 comments

Comments

@larsw
Copy link

larsw commented Oct 25, 2023

Hi,

I'm trying to use lmdb-js with bun (1.0.7) but it just hangs (as far as I can see, it's able to create/open the database, but not doing put/get with or without a transaction.

Is there any way I can try to diagnose this further?

@larsw
Copy link
Author

larsw commented Oct 26, 2023

import { open } from 'lmdb'; // or require
let myDB = open({
	path: 'my-db',

});

await myDB.put('greeting', { someText: 'Hello, World!' });
console.log(myDB.get('greeting').someText)

await myDB.transaction(() => {
	myDB.put('greeting', { someText: 'Hello, World!' });
	myDB.get('greeting').someText // 'Hello, World!'
    console.log('Hello, World! in tx');
});

Seems like the non-transactional code works, but not the put/get happening in a transaction.

@kriszyp
Copy link
Owner

kriszyp commented Oct 27, 2023

Asynchronous transaction callbacks require threadsafe calls, and I believe that has not been fully implemented (correctly) in Bun:
oven-sh/bun#158 (comment)

Note that you can still execute multiple puts in the same event turn or same batch and they will be transactionally committed together, it is the async transaction callback that can't function without the NAPI threadsafe call system.

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

2 participants