tulios / kafkajs

A modern Apache Kafka client for node.js
https://kafka.js.org
MIT License
3.75k stars 527 forks source link

kafkajs is not compatible with Nodev18 #1662

Open saifahmedkhan9 opened 9 months ago

saifahmedkhan9 commented 9 months ago

Using

On upgrading nodejs version from 16 to 18. kafkajs lz4 library is throwing below errors :

TypeError: Failed to parse URL from /home/user/appName/node_modules/lz4-asm/dist/_lz4.wasm
    at Object.fetch (node:internal/deps/undici/undici:11730:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  [cause]: TypeError [ERR_INVALID_URL]: Invalid URL
      at new NodeError (node:internal/errors:405:5)
      at new URL (node:internal/url:676:13)
      at new Request (node:internal/deps/undici/undici:5270:25)
      at fetch (node:internal/deps/undici/undici:9508:25)
      at Object.fetch (node:internal/deps/undici/undici:11728:18)
      at fetch (node:internal/process/pre_execution:281:25)
      at /home/user/appName/node_modules/lz4-asm/dist/lz4wasm.js:21:123
      at /home/user/appName/node_modules/lz4-asm/dist/lz4wasm.js:21:344
      at /home/user/appName/node_modules/lz4-asm/dist/lz4wasm.js:21:357
      at Object.<anonymous> (/home/user/appName/node_modules/kafkajs-lz4/lib/index.js:5:18)
      at Module._compile (node:internal/modules/cjs/loader:1356:14)
      at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
      at Module.load (node:internal/modules/cjs/loader:1197:32)
      at Module._load (node:internal/modules/cjs/loader:1013:12)
      at Module.require (node:internal/modules/cjs/loader:1225:19)
      at require (node:internal/modules/helpers:177:18) {
    input: '/home/user/appName/node_modules/lz4-asm/dist/_lz4.wasm',
    code: 'ERR_INVALID_URL'
  }
}

/home/user/appName/node_modules/lz4-asm/dist/lz4wasm.js:12
if(r)t=q?require("path").dirname(t)+"/":__dirname+"/",u=function(a,b){w||(w=require("fs"));x||(x=require("path"));a=x.normalize(a);return w.readFileSync(a,b?null:"utf8")},v=function(a){a=u(a,!0);a.buffer||(a=new Uint8Array(a));a.buffer||y("Assertion failed: undefined");return a},1<process.argv.length&&process.argv[1].replace(/\\/g,"/"),process.argv.slice(2),process.on("uncaughtException",function(a){if(!(a instanceof z))throw a;}),process.on("unhandledRejection",y),n=function(a){process.exit(a)},
                                                                                                                                                                                                                                                                                                                                                                                                                                        ^

RuntimeError: abort(TypeError: Failed to parse URL from /home/user/appName/node_modules/lz4-asm/dist/_lz4.wasm). Build with -s ASSERTIONS=1 for more info.
    at process.y (/home/user/appName/node_modules/lz4-asm/dist/lz4wasm.js:16:393)
    at process.emit (node:events:517:28)
    at emit (node:internal/process/promises:149:20)
    at processPromiseRejections (node:internal/process/promises:283:27)
    at process.processTicksAndRejections (node:internal/process/task_queues:96:32)

Node.js v18.19.0
vkbera commented 8 months ago

any update on this issue??

joras commented 8 months ago

i guess the underlying issue is https://github.com/ukyo/lz4.js/issues/14

joras commented 8 months ago

the whole thing should be quite easy to fix, i guess the whole chain down to lz4 is not maintained :)

ptrpiero commented 7 months ago

The issue is not present with version of Kafkajs-lz4 lower than 2.0.0-beta.0 (tested with 1.2.1 and it works)

aman-goyal-git commented 6 months ago

any fix for this issue ? I am also seeing the same error when using kafkajs with Node v18. It works fine with Node v16.