Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] L4Z implementation is broken on nodejs18 #1543

Open
eau-de-la-seine opened this issue Feb 27, 2023 · 3 comments
Open

[bug] L4Z implementation is broken on nodejs18 #1543

eau-de-la-seine opened this issue Feb 27, 2023 · 3 comments

Comments

@eau-de-la-seine
Copy link

Describe the bug

Hi, the L4Z implementation suggested in the documentation is broken on nodejs18

To Reproduce

npm install kafkajs-lz4
import { Message, CompressionCodecs, CompressionTypes } from 'kafkajs';
import LZ4Codec from 'kafkajs-lz4';

// Initialize L4Z implementation
CompressionCodecs[CompressionTypes.LZ4] = new LZ4Codec().codec;

// ...
await producer.send({
  topic,
  messages,
  compression: CompressionTypes.LZ4,
});

Observed behavior

The error is about the _lz4.wasm file:

RuntimeError: abort(RuntimeError: abort(Error: ENOENT: no such file or directory, open '/var/task/_lz4.wasm'). Build with -s ASSERTIONS=1 for more info.). Build with -s ASSERTIONS=1 for more info.

Environment:

  • OS: AWS Lambda
  • KafkaJS version 2.2.3
  • NodeJS version: 18

Additional context

The issue has already been reported, and there's a hackaround that doesn't work for me, surely because I use esbuild.

The kafkajs-lz4 implementation seems veeeery old (+2y without a commit, and still in beta), do you have an alternative? Thanks

@bjornmolin
Copy link

bjornmolin commented Mar 10, 2023

We switched to lz4-kafkajs yesterday (also nodejs 18)

@douglasg14b
Copy link

Seeing this on Node16 as well for some reason.

Also on Node 18 too.

@ArthurGLACET
Copy link

ArthurGLACET commented Jul 3, 2023

Hello all,

I'm having the issue too, here what i've made:

on documentation it's written that you can easely create you own codec:

const lz4 = require('lz4'); // using https://www.npmjs.com/package/lz4

module.exports = {
    /**
     * @param {Encoder} encoder
     * @returns {Promise}
     */
    async compress(encoder) {
        return lz4.encode(encoder.buffer);
    },
  
    /**
     * @param {Buffer} buffer
     * @returns {Promise}
     */
    async decompress(buffer) {
        return lz4.decode(buffer);
    },
  }

and then :

const { Kafka, CompressionTypes, CompressionCodecs } = require('kafkajs');
const lz4Codec = require('lz4Codec');

CompressionCodecs[CompressionTypes.LZ4] = () => lz4Codec;

const kafka = new Kafka({
        brokers: [broker],
        clientId: 'test client',
    });

const producer = kafka.producer();
await producer.connect();
await producer.send({
    compression: CompressionTypes.LZ4,
    topic: topic,
    messages: [{value: message}],
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants