Skip to content

rtc-node package fails on any musl-based OS but the error message does not make this clear #484

Open
@sjgutta

Description

@sjgutta

Select which package(s) are affected

@livekit/rtc-node

Describe the bug

Anytime you try to use the rtc-node package on a musl-based distribution, it fails due to an import in src/napi/native.cjs

The code there tries to import a path with musl in it, which does not exist. This leads to a failed import. On the surface, this seems like something is wrong with the user's dependencies or how they are building the project, and doesn't make it obvious that musl is actually just not supported at all. I think this code should improved to actually indicate that musl is just not supported. Otherwise, the only way to debug this is to dive all the way into the source code of the package and infer that this is the case

 if (isMusl()) {
          localFileExisted = existsSync(join(__dirname, 'rtc-node.linux-x64-musl.node'));
          try {
            if (localFileExisted) {
              nativeBinding = require('./rtc-node.linux-x64-musl.node');
            } else {
              nativeBinding = require('@livekit/rtc-node-linux-x64-musl');
            }
          } catch (e) {
            loadError = e;
          }
        } else {
          localFileExisted = existsSync(join(__dirname, 'rtc-node.linux-x64-gnu.node'));
          try {
            if (localFileExisted) {
              nativeBinding = require('./rtc-node.linux-x64-gnu.node');
            } else {
              nativeBinding = require('@livekit/rtc-node-linux-x64-gnu');
            }
          } catch (e) {
            loadError = e;
          }
        }
        break;

Reproduction

Run the app on any hosted musl-based OS (e.g. using node alpine on linux)

Logs

System Info

It failed for me on node 22 alpine, running on AWS linux. Worked once I used a regular node distro

LiveKit server version

LiveKit cloud

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions