apache / pulsar-client-node

Apache Pulsar NodeJS Client
https://pulsar.apache.org/
Apache License 2.0
148 stars 86 forks source link

Support for node version 17+ #299

Closed ingimarlego closed 1 year ago

ingimarlego commented 1 year ago

When upgrading node to 17/18, the library does not work.

Error: Error relocating /node_modules/pulsar-client/lib/binding/Pulsar.node: _ZSt28__throw_bad_array_new_lengthv: symbol not found at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18) at Module.load (node:internal/modules/cjs/loader:975:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:999:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (/node_modules/pulsar-client/src/pulsar-binding.js:24:17) at Module._compile (node:internal/modules/cjs/loader:1099:14) at Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Object.require.extensions.<computed> [as .js] (/node_modules/ts-node/src/index.ts:1608:43) at Module.load (node:internal/modules/cjs/loader:975:32) { code: 'ERR_DLOPEN_FAILED' }

shibd commented 1 year ago

Can you share your system env and pulsar-client-node version?

ingimarlego commented 1 year ago

It's running on docker image node:16-alpine. bumping the image to 17 or 18 triggers the issue.


"node_modules/pulsar-client": {
      "version": "1.8.0",
      "hasInstallScript": true,
      "license": "Apache-2.0",
      "dependencies": {
        "@mapbox/node-pre-gyp": "^1.0.9",
        "bindings": "^1.5.0",
        "node-addon-api": "^4.3.0"
      },
      "engines": {
        "node": ">=10.16.0"
      }
    }
shibd commented 1 year ago

I reproduce the same problem with node:17-alpine, but not reproduced on node:18-alpine (with v18.11.0)

node:internal/modules/cjs/loader:1183
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: Error relocating /test/node_modules/pulsar-client/lib/binding/Pulsar.node: _ZSt28__throw_bad_array_new_lengthv: symbol not found
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/test/node_modules/pulsar-client/src/pulsar-binding.js:24:17)
    at Module._compile (node:internal/modules/cjs/loader:1099:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
  code: 'ERR_DLOPEN_FAILED'
}

Node.js v17.9.1
shibd commented 1 year ago

The root cause is that pulsar-client is not compatible with alpine3.15. You can confirm that all the error environment alpine versions <= 3.15

cat /etc/alpine-release

304 will fix it. Before this, you can use the alpine > 3.15 version. For example:

BTW: I don't find node:17-alpine3.16 version in the docker hub