bun icon indicating copy to clipboard operation
bun copied to clipboard

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

Open xhyrom opened this issue 1 year ago • 61 comments

Affected packages

  • [ ] better-sqlite3
  • [ ] node-canvas@v2 (node-canvas v3 is supported)
  • [ ] midi
  • [ ] libxmljs
  • [ ] bignum
  • [ ] zeromq
  • [ ] node-libcurl
  • [ ] bson-ext
  • [ ] heapdump
  • [ ] @datadog/native-metrics
  • [ ] tiny-secp256k1
  • [ ] tree-sitter-c-sharp
  • [ ] chacha-native
  • [ ] @sentry/profiling-node
  • [ ] pdfjs-dist
  • [ ] gl
  • [ ] leveldown / pouchdb
  • [x] sleep
  • [x] cpu-features
  • [ ] odbc
  • [ ] msgpackr
  • [ ] re2
  • [ ] node-pty
  • [ ] i2c

Functions implemented

  • [x] v8::Isolate::GetCurrent()
  • [x] v8::Isolate::TryGetCurrent()
  • [x] v8::Isolate::GetCurrentContext()
  • [x] v8::Number::New(v8::Isolate*, double)
  • [x] v8::Number::Value() const
  • [x] v8::String::NewFromUtf8(v8::Isolate*, char const*, v8::NewStringType, int)
  • [x] v8::String::WriteUtf8(v8::Isolate*, char*, int, int*, int) const
  • [x] v8::api_internal::ToLocalEmpty()
  • [x] v8::String::Length() const
  • [x] v8::External::New(v8::Isolate*, void*)
  • [x] v8::External::Value() const
  • [x] v8::Object::New(v8::Isolate*)
  • [x] v8::Object::Set(v8::Local<v8::Context>, v8::Local<v8::Value>, v8::Local<v8::Value>)
  • [x] v8::Object::SetInternalField(int, v8::Local<v8::Data>)
  • [x] v8::Object::SlowGetInternalField(int)
  • [x] v8::HandleScope::HandleScope(v8::Isolate*)
  • [x] v8::HandleScope::~HandleScope()
  • [x] v8::FunctionTemplate::GetFunction(v8::Local<v8::Context>)
  • [x] v8::FunctionTemplate::New(v8::Isolate*, void (*)(v8::FunctionCallbackInfo<v8::Value> const&), v8::Local<v8::Value>, v8::Local<v8::Signature>, int, v8::ConstructorBehavior, v8::SideEffectType, v8::CFunction const*, unsigned short, unsigned short, unsigned short) (only when all parameters past data are their default values)
  • [x] v8::ObjectTemplate::NewInstance(v8::Local<v8::Context>)
  • [x] v8::ObjectTemplate::SetInternalFieldCount(int)
  • [x] v8::ObjectTemplate::InternalFieldCount() const
  • [x] v8::ObjectTemplate::New(v8::Isolate*, v8::Local<v8::FunctionTemplate>) (only when no FunctionTemplate is provided)
  • [x] v8::EscapableHandleScopeBase::EscapeSlot(unsigned long*)
  • [x] v8::EscapableHandleScopeBase::EscapableHandleScopeBase(v8::Isolate*)
  • [x] node_module_register
  • [x] v8::Function::SetName(v8::Local<v8::String>)
  • [x] v8::Value::IsBoolean() const
  • [x] v8::Boolean::Value() const
  • [x] v8::Value::FullIsTrue() const
  • [x] v8::Value::FullIsFalse() const
  • [x] v8::EscapableHandleScope::EscapableHandleScope(v8::Isolate*)
  • [x] v8::EscapableHandleScope::~EscapableHandleScope()
  • [x] v8::Value::IsObject() const
  • [x] v8::Value::IsNumber() const
  • [x] v8::Value::IsUint32() const
  • [x] v8::Value::Uint32Value(v8::Local<v8::Context>) const
  • [x] v8::Value::IsUndefined() const
  • [x] v8::Value::IsNull() const
  • [x] v8::Value::IsNullOrUndefined() const
  • [x] v8::Value::IsTrue() const
  • [x] v8::Value::IsFalse() const
  • [x] v8::Value::IsString() const
  • [x] v8::Boolean::New(v8::Isolate*, bool)
  • [x] v8::Object::GetInternalField(int)
  • [ ] node::AddEnvironmentCleanupHook(v8::Isolate*, void (*)(void*), void*)
  • [ ] node::RemoveEnvironmentCleanupHook(v8::Isolate*, void (*)(void*), void*)
  • [x] v8::HandleScope::CreateHandle(v8::internal::Isolate*, unsigned long)
  • [ ] v8::internal::IsolateFromNeverReadOnlySpaceObject(unsigned long)
  • [ ] v8::Array::New(v8::Isolate*, v8::Local<v8::Value>*, unsigned long)
  • [ ] v8::Object::Get(v8::Local<v8::Context>, v8::Local<v8::Value>)

Major areas of unimplemented functionality

  • [ ] Array
  • [ ] ObjectTemplate with a constructor function
  • [ ] Less-simple cases of FunctionTemplate
  • [ ] ArrayBuffer
  • [ ] bun install fixes (need to pass node-gyp the right version)
  • [x] Doubles
  • [x] UTF-16 strings
  • [x] Persistent handles

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

xhyrom avatar Aug 24 '23 08:08 xhyrom

This also happens for node-libcurl

floydjones1 avatar Aug 24 '23 14:08 floydjones1

I also encounter this error

issadarkthing avatar Sep 10 '23 04:09 issadarkthing

this also happens for bson-ext

Zykatious avatar Sep 10 '23 21:09 Zykatious

also for heapdump

autoscatto avatar Sep 11 '23 08:09 autoscatto

same for @datadog/native-metrics

vroudge avatar Sep 15 '23 10:09 vroudge

Likewise for tiny-secp256k1

uditdc avatar Sep 16 '23 09:09 uditdc

Also for cdktf-cli #5306

ozyman42 avatar Sep 24 '23 00:09 ozyman42

Also happens with tree-sitter-c-sharp

obedm503 avatar Sep 28 '23 13:09 obedm503

Same error for chacha-native

Scitz0 avatar Sep 28 '23 16:09 Scitz0

same for node-canvas

metawrap-dev avatar Oct 26 '23 02:10 metawrap-dev

bun: symbol lookup error: /root/rut/node_modules/canvas/build/Release/canvas.node: undefined symbol: node_module_register same for canvas

4i8 avatar Oct 28 '23 00:10 4i8

Same for libxmljs

edi9999 avatar Oct 28 '23 10:10 edi9999

How can we get a little more attention to this. This is holding me back from using bun in production. :cry: node-libcurl

bun: symbol lookup error: /home/.../node_modules/node-libcurl/lib/binding/node_libcurl.node: undefined symbol: node_module_register

floydjones1 avatar Nov 13 '23 11:11 floydjones1

bun: symbol lookup error: /root/rut/node_modules/canvas/build/Release/canvas.node: undefined symbol: node_module_register same for canvas

me too

M-Gonzalo avatar Nov 17 '23 06:11 M-Gonzalo

similar error:

bun: symbol lookup error: /usr/src/app/node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-linux-x64-glibc-115.node: undefined symbol: _ZN2v87Isolate10GetCurrentEv

frani avatar Nov 26 '23 01:11 frani

Also happening for Sentry & bcrypt Sentry code: Code:

const Sentry = require('@sentry/bun');
const { ProfilingIntegration } = require("@sentry/profiling-node")

Error:

bun: symbol lookup error: /root/projects/userBackend/node_modules/@sentry/profiling-node/lib/sentry_cpu_profiler-linux-x64-glibc-115.node: undefined symbol: _ZN2v87Isolate10GetCurrentEv

xbura1han avatar Nov 27 '23 12:11 xbura1han

Same for https://github.com/TulipCharts/tulipnode

bun: symbol lookup error: node_modules/tulind/lib/binding/Release/node-v115-linux-x64/tulind.node: undefined symbol: node_module_register

movy avatar Dec 01 '23 08:12 movy

node_module_register uses & expects V8 C++ APIs. Bun uses JavaScriptCore, an entirely different JavaScript engine. This is especially challenging for Bun to support, but not without precedent. node-jsc did it.

Jarred-Sumner avatar Dec 01 '23 09:12 Jarred-Sumner

Same with New Relic

Wamy-Dev avatar Mar 11 '24 06:03 Wamy-Dev

Same for https://github.com/zeromq/zeromq.js

bun: symbol lookup error: node_modules/zeromq/prebuilds/linux-x64/node.napi.glibc.node: undefined symbol: uv_async_init

Arilith avatar Mar 18 '24 13:03 Arilith

node_libcurl.node: undefined symbol: node_module_register wen node-libcurl

bonald avatar Mar 29 '24 06:03 bonald

bun: symbol lookup error: .../node_modules/gl/build/Release/webgl.node: undefined symbol: node_module_register

deadblue22 avatar Apr 10 '24 14:04 deadblue22

Trying to use @testcontainers/postgresql also leads to the node_module_register error

ellis avatar Apr 20 '24 16:04 ellis

Same in pdfjs-dist (related to canvas).

ibilux avatar May 01 '24 13:05 ibilux

This blocks using node-gtk in combination with bun build --compile to produce standalone GTK apps.

terrablue avatar May 05 '24 13:05 terrablue

Trying to use pcsclite also leads to the node_module_register error

celso-alexandre avatar May 07 '24 12:05 celso-alexandre

Also node-pty , Release/pty.node: undefined symbol: node_module_register

jimying avatar May 09 '24 06:05 jimying

I also need this for my project.

ralyodio avatar May 12 '24 13:05 ralyodio

I also get this error with the opencv bindings:

bun: symbol lookup error: /home/arthur/dev/ai/manga/node_modules/opencv4nodejs/build/Release/opencv4nodejs.node: undefined symbol: node_module_register

what is the status on this, is there anything I can do to get it to run ?

arthurwolf avatar May 26 '24 18:05 arthurwolf

I also encountered this problem. This question has been raised for a long time. Is there still no solution?

826327700 avatar May 27 '24 08:05 826327700