denoland / deno

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

Deno panicked trying to run ZeroMQ from NPM package #18345

Open welsonjr opened 1 year ago

welsonjr commented 1 year ago

While trying to run the code bellow:

import zmq from "npm:zeromq@5"

async function run(): Promise<void> {
  const sock = new zmq.Pull

  sock.connect("tcp://127.0.0.1:3000")
  console.log("Worker connected to port 3000")

  for await (const [msg] of sock) {
    console.log("work: %s", msg.toString())
  }
}

run()

Deno panicked

Platform: macos x86_64 Version: 1.31.3 Args: ["deno", "run", "zmq-worker.ts"]

thread 'main' panicked at 'napi_register_module_v1 not found: DlSym { desc: "dlsym(0x7fc9dd4391d0, napi_register_module_v1): symbol not found" }', /private/tmp/deno-20230316-8411-14pm5ia/deno/ext/napi/lib.rs:707:14 stack backtrace: 0: 0x108dee56a - ::fmt::hd84bb6a6cfdab3c7 1: 0x10834fc9a - core::fmt::write::h064e45b009bad019 2: 0x108dc976c - std::io::Write::write_fmt::h2baab28417cc385e 3: 0x108dee35a - std::sys_common::backtrace::print::h40507d34f683de75 4: 0x108dccd63 - std::panicking::default_hook::{{closure}}::h41d95177e478a814 5: 0x108dcca74 - std::panicking::default_hook::h92082f3783ffd863 6: 0x1082d6e24 - deno::setup_panic_hook::{{closure}}::hb16ad9950d35c310 7: 0x108dcd602 - std::panicking::rust_panic_with_hook::h7164f539cab4c561 8: 0x108dee9e5 - std::panicking::begin_panic_handler::{{closure}}::h0697ed62d1c15d34 9: 0x108dee948 - std::sys_common::backtrace::rust_end_short_backtrace::h035e1452da26fb2c 10: 0x108dcd172 - _rust_begin_unwind 11: 0x10a2599c3 - core::panicking::panic_fmt::h619520ac8a6ef893 12: 0x10a259e25 - core::result::unwrap_failed::h5bb33123d8199612 13: 0x10888d983 - <extern "C" fn(A0) .> R as v8::support::CFnFrom>::mapping::c_fn::hd22173f4c0d0adf0 14: 0x1091d5e3f - __ZN2v88internal12_GLOBALN_119HandleApiCallHelperILb0EEENS0_11MaybeHandleINS0_6ObjectEEEPNS0_7IsolateENS0_6HandleINS0_10HeapObjectEEENS8_INS0_20FunctionTemplateInfoEEENS8_IS4_EEPmi 15: 0x1091d5435 - __ZN2v88internal21Builtin_HandleApiCallEiPmPNS0_7IsolateE

bartlomieju commented 1 year ago

I just tried it with latest Deno and I get:

deno run -A foo.ts
error: Uncaught Error: No native build was found for platform=darwin arch=arm64 runtime=node abi=108 uv=1 armv=8 libc=glibc node=18.12.1
    loaded from: /Users/ib/dev/deno-parcel-bug/node_modules/.deno/zeromq@5.3.1/node_modules/zeromq

    at Function.load.resolve.load.path (file:///Users/ib/dev/deno-parcel-bug/node_modules/.deno/node-gyp-build@4.6.0/node_modules/node-gyp-build/node-gyp-build.js:60:9)
    at load (file:///Users/ib/dev/deno-parcel-bug/node_modules/.deno/node-gyp-build@4.6.0/node_modules/node-gyp-build/node-gyp-build.js:22:30)
    at Object.<anonymous> (file:///Users/ib/dev/deno-parcel-bug/node_modules/.deno/zeromq@5.3.1/node_modules/zeromq/binding.js:1:308)

Could you try it on your side @welsonjr and let me know if this is still a problem?

welsonjr commented 1 year ago

Unfortunately the error still persists.

Platform: macos x86_64
Version: 1.34.0
Args: ["deno", "run", "-A", "zmq-worker.ts"]

thread 'main' panicked at 'napi_register_module_v1 not found: DlSym { desc: "dlsym(0x7f7f3e410020, napi_register_module_v1): symbol not found" }', /private/tmp/deno-20230525-9595-kb9wji/deno/ext/napi/lib.rs:667:14
stack backtrace:
   0:        0x1107fdd7a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h28eefff2fd6348c0
   1:        0x10fd669ea - core::fmt::write::h49021f0d249bdcdd
   2:        0x1107ee78c - std::io::Write::write_fmt::hfe905b75ea2975e8
   3:        0x1107fdb6a - std::sys_common::backtrace::print::h729e4781fcd708bf
   4:        0x1107e8d73 - std::panicking::default_hook::{{closure}}::he34a760df1040d15
   5:        0x1107e8a84 - std::panicking::default_hook::hc21c623951eeae76
   6:        0x110da1804 - deno::setup_panic_hook::{{closure}}::h7a849f342d0aa904
   7:        0x1107e974d - std::panicking::rust_panic_with_hook::hf3038b3a4cc27e74
   8:        0x1107fe0e5 - std::panicking::begin_panic_handler::{{closure}}::h167648f6debe79bf
   9:        0x1107fe049 - std::sys_common::backtrace::__rust_end_short_backtrace::h998cad6508c9fd44
  10:        0x1107e9182 - _rust_begin_unwind
  11:        0x111f7de53 - core::panicking::panic_fmt::h0c7b66c2bc0c7be6
  12:        0x111f7e2b5 - core::result::unwrap_failed::h534fb7147885e41d
  13:        0x1103cd338 - deno_napi::op_napi_open::v8_fn_ptr::h70c34adb0dec6503
  14:        0x110fd7e0e - __ZN2v88internal12_GLOBAL__N_119HandleApiCallHelperILb0EEENS0_11MaybeHandleINS0_6ObjectEEEPNS0_7IsolateENS0_6HandleINS0_10HeapObjectEEENS8_INS0_20FunctionTemplateInfoEEENS8_IS4_EEPmi
  15:        0x110fd7577 - __ZN2v88internal21Builtin_HandleApiCallEiPmPNS0_7IsolateE
anggoran commented 11 months ago

I think this error is not caused by Deno. I tried to install in an Express project and got error too. It looks like zeromq.js has some bugs on the build and its dependencies:

I tried to use zeromq in Rust and Python and they requires no extra setup, while I think the Node library is different.

Actually, there is also a big news from the maintainer: https://github.com/zeromq/zeromq.js/issues/576