denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
97.68k stars 5.38k forks source link

Support lmdb-js #23268

Open alexgleason opened 7 months ago

alexgleason commented 7 months ago

I'm building an application in Deno that uses lmdb-js, and we hit a snag where asyncronous transactions don't work on Deno, which we believe is due to this issue (from the lmdb-js README):

Note that Deno and Bun's support for NAPI is not very stable yet, and currently asynchronous transactions (transaction method) are not supported (Bun issue https://github.com/oven-sh/bun/issues/158#issuecomment-1126624085).

From what we can tell, the "Asynchronous thread-safe function calls" family of functions is not implemented, and may be what's causing this:

image

Having Deno + LMDB would be a big win for us. And I believe there's unexplored potential with Deno KV as well (eg creating a wrapper for lmdb-js that implements the Deno.KV interface https://github.com/kriszyp/lmdb-js/discussions/236)

cc @kriszyp @xyzshantaram

bartlomieju commented 7 months ago

Do you have a specific error that is raised? From what I can see we do implement these APIs.

kriszyp commented 7 months ago

If I recall correctly, the issue is that https://github.com/nodejs/node-addon-api calls napi_release_threadsafe_function, which is supposed to trigger the thread_finalize_cb, but it does not happen. So there is no error that is raised, it is absence of calling the callback that is problem (so a program that is waiting for that callback just hangs).

alexgleason commented 7 months ago

so a program that is waiting for that callback just hangs

This is exactly what we're experiencing.

bartlomieju commented 7 months ago

Thanks for detailed explanation. @littledivy is this something you could put in your backlog?

devsnek commented 5 months ago

I think this should be fixed in https://github.com/denoland/deno/pull/24101. If you have repro code I'd be happy to confirm.