oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
74.47k stars 2.78k forks source link

Support V8 C++ APIs for "nan" addons and other packages to work #4290

Open xhyrom opened 1 year ago

xhyrom commented 1 year ago

Affected packages

Functions implemented

Major areas of unimplemented functionality

What version of Bun is running?

0.8.0+ad326b77342dd3d8585a30b7da803d32f9c11fe2

What platform is your computer?

Linux 6.4.10-artix1-1 x86_64 unknown

What steps can reproduce the bug?

import Database from 'better-sqlite3';
const db = new Database('foobar.db', {});

console.log(db.prepare("CREATE TABLE TEST").run());

What is the expected behavior?

Run as normally

What do you see instead?

/usr/bin/bun: symbol lookup error: /home/hyro/Workspace/booo/node_modules/better-sqlite3/build/Release/better_sqlite3.node: undefined symbol: node_module_register

Additional information

Related thread: 1144181146809270332 Message: https://discord.com/channels/876711213126520882/1144181146809270332/1144184224006557747

All versions are affected

jerrywoo96 commented 3 months ago

Is there a list or is anyone able to make a list of packages that are not yet resolved or implemented? This issue thread is becoming too large to keep track of which packages are still outstanding.

190n commented 3 months ago

That exists in the top comment on this issue, but it probably deserves to be the most prominent part instead of the list of functions. I'll move it to the top.

rgillan commented 3 months ago

@190n if you could add msgpackr to the list as well please, although will be ok once Array::New is done I expect. Really appreciate all your efforts on this.

190n commented 3 months ago

Right, thanks for the reminder.

etcd commented 2 months ago

@190n thoughts on also adding re2 to the list (given that issue https://github.com/oven-sh/bun/issues/12560 was marked as a duplicate of this one)?

karlhorky commented 2 months ago

@190n also node-pty, following these comments:

nachat-ayoub commented 1 month ago

how much time could it take to support the "gl" module?

adworacz commented 1 month ago

@190n if you could add msgpackr to the list as well please, although will be ok once Array::New is done I expect. Really appreciate all your efforts on this.

For anyone else who's confused by this - technically msgpackr does support Bun, it's just the "native acceleration" feature that msgpackr has that won't work.

rgillan commented 1 month ago

@190n if you could add msgpackr to the list as well please, although will be ok once Array::New is done I expect. Really appreciate all your efforts on this.

For anyone else who's confused by this - technically msgpackr does support Bun, it's just the "native acceleration" feature that msgpackr has that won't work.

so there's been investigation by @190n back in July when we first found this, and you can find more in #12754 with their findings. One of the great things with msgpackr is the native acceleration, and that needs v8::Array::New

190n commented 1 month ago

One of the great things with msgpackr is the native acceleration, and that needs v8::Array::New

As an update on that, I'm not sure if we'll be able to support their specific use of v8::Array::New, because they're using it by casting an array of NAPI values into an array of V8 values. That only works if NAPI values are V8 values, which is true in Node but not Bun. So while we can get v8::Array::New working for packages using the V8 API normally, for msgpackr specifically I think the solution would be more along the lines of finding out why they detect us as Node and stopping that from happening. So ideally their native acceleration can still work in Bun but it should be using exclusively NAPI functions instead of mixing NAPI and V8.

Frtrillo commented 1 month ago

Same issue for @newrelic/native-metrics and symbol lookup

Jean-Daniel commented 2 weeks ago

There is also missing symbols for unix-gram (v8::Integer::New(v8::Isolate*, int) at least).