Skip to content

Unable to run inside node:16-alpine #97

@blesson3

Description

@blesson3

Issue

On the docker image node:16-alpine (musl) using the linux/amd64 platform skia-canvas seems to crash when importing. There's a repo below to help reproduce. Using the image node:16-slim (glibc) works fine.

$ node -e "require('skia-canvas')"
node:internal/modules/cjs/loader:1189
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: Error relocating /usr/src/demo/node_modules/skia-canvas/lib/v6/index.node: _ZSt28__throw_bad_array_new_lengthv: symbol not found
    at Object.Module._extensions..node (node:internal/modules/cjs/loader:1189:18)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/usr/src/demo/node_modules/skia-canvas/lib/index.js:23:29)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
  code: 'ERR_DLOPEN_FAILED'
}

According to the docs, this should work with Alpine Linux (x64) and the musl C library it favors.

I've done quite a bit of searching to see if I could fix the issue, but it looks out of my depth to solve. Seems to be that may be the musl vs glibc libraries that may be causing the issue.

Let me know if there is anything I'm missing here or could do to help!

Reproduce

I built a small barebones repo to reproduce: https://github.com/blesson3/skia-canvas-crash-repro

Here's the dockerfile used to reproduce (in the repo)

FROM node:16-alpine

RUN apk update && apk add --no-cache fontconfig

WORKDIR /usr/src/demo

RUN npm init -y
RUN npm i --save skia-canvas

ENTRYPOINT [ "node", "-e", "require('skia-canvas'); console.log('what bug?');" ]

Run the build-and-run.sh script to reproduce. The README has additional information on reproducing.

Workaround in the meantime

To workaround this issue, I am using node:16-slim which uses glibc instead of musl. The hassle here is the image is much larger (inconvenient for dev) and having to refactor apt-get as a package manager instead of apk.


Thank you for your work on this package! (love that you used rust for this 🦀)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions