libsql-client-ts: strcpy_chk: symbol not found

I’m trying to package my API into a docker image, using node:20-alpine.

Running my app leads to

2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] node:internal/modules/cjs/loader:1473
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] return process.dlopen(module, path.toNamespacedPath(filename));
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] ^
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] Error: Error relocating /app/node_modules/@libsql/linux-x64-musl/index.node: __strcpy_chk: symbol not found
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] at Module._extensions..node (node:internal/modules/cjs/loader:1473:18)
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] at Module.load (node:internal/modules/cjs/loader:1207:32)
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] at Module._load (node:internal/modules/cjs/loader:1023:12)
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] at Module.require (node:internal/modules/cjs/loader:1235:19)
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] at require (node:internal/modules/helpers:176:18)
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] at Object.<anonymous> (/app/node_modules/libsql/index.js:41:24)
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] at Module._compile (node:internal/modules/cjs/loader:1376:14)
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] at Module.load (node:internal/modules/cjs/loader:1207:32)
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] at Module._load (node:internal/modules/cjs/loader:1023:12) {
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] code: 'ERR_DLOPEN_FAILED'
2024-02-17T11:15:12.739 app[080e513b19e298] ams [info] } 

It might be an issue with glibc/musl. See this issue

Do the libsql team have an opinion of what type of distribution I should use?

Dockerfile
FROM node:20-alpine as base

WORKDIR /app
COPY ./dist /app/dist

ARG GIT_SHA
ENV GIT_REVISION=$GIT_SHA

RUN npm install @libsql/client

EXPOSE 4000
CMD [ "node", "--no-warnings=ExperimentalWarning", "dist/index.js" ]

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 27 (4 by maintainers)

Commits related to this issue

Most upvoted comments

Thanks for the updates, the fcntl64: symbol not found error remains with the new version when testing with latest Alpine Edge:

# cat node_modules/@libsql/linux-x64-musl/package.json | grep version
  "version": "0.3.9",

# ldd node_modules/@libsql/linux-x64-musl/index.node 
	/lib/ld-musl-x86_64.so.1 (0x76c8197f6000)
	libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x76c818f42000)
	libc.so => /lib/ld-musl-x86_64.so.1 (0x76c8197f6000)
Error relocating node_modules/@libsql/linux-x64-musl/index.node: fcntl64: symbol not found

The fcntl64 symbol is glibc-only and was introduced in glibc 2.28.

v0.4.3 of libsql is out so if you run an npm update you should pick it up and should solve both the strcpy issue and the recent fcntl64 issues.

@RA9 This problem remains and now there are duplicate reports appearing e.g. https://github.com/tursodatabase/libsql-js/issues/91

The summary is that the @libsql/linux-x64-musl package provided from v0.3.1 onwards, including the latest v0.3.10, does not work on musl-based systems.

I did some digging it looks like there were some larger issues with our Rust/C code that we built the js library (which TS uses). This PR should fix those issues and subsequent TS/Js issues https://github.com/tursodatabase/libsql/pull/1724

As a workaround we downgrading from v5.x to v0.4.3 tested to work with node:18-alpine and node:20-alpine (at least for now)

It’s a workaround, but not a solution. Bookworm, bullseye or even distroless images work but are consuming more RAM compare to Alpine (15/20% more). In environment where you want to control cost on memory usage, Alpine is still the most optimised.

PS: You can probably use slim rather than the whole bookworm as well

@LukaGiorgadze not sure if it works for your setup, but I am using yarn v3 and as such can ensure I am using a version of libsql that works with alpine by adding this to the root package.json of my monorepo.

"resolutions": {
    "@libsql/linux-x64-musl@npm:0.3.15": "0.2.0"
},

For npm-users i guess overrides should be the equivalent -> https://docs.npmjs.com/cli/v10/configuring-npm/package-json#overrides

Tried, but did not work 😕

@LukaGiorgadze not sure if it works for your setup, but I am using yarn v3 and as such can ensure I am using a version of libsql that works with alpine by adding this to the root package.json of my monorepo.

"resolutions": {
    "@libsql/linux-x64-musl@npm:0.3.15": "0.2.0"
},

For npm-users i guess overrides should be the equivalent -> https://docs.npmjs.com/cli/v10/configuring-npm/package-json#overrides

Hey @penberg, should this issue be reopened? It doesn’t seem like the above proposed fix actually solved whatever the issue is for musl builds 😕

@flexchar That is my understanding, yes, but I’m only the messenger here. You’ll need to ask one of the maintainers about the future possible re-introduction of support for musl-based Linux.

Ran into this problem while trying to build a astro application with the db integration. Wont build using node:lts-alpine

#0 2.037 node:internal/modules/cjs/loader:1473
#0 2.037   return process.dlopen(module, path.toNamespacedPath(filename));
#0 2.037                  ^
#0 2.037
#0 2.037 Error: Error relocating /app/node_modules/@libsql/linux-x64-musl/index.node: fcntl64: symbol not found
#0 2.037     at Module._extensions..node (node:internal/modules/cjs/loader:1473:18)
#0 2.037     at Module.load (node:internal/modules/cjs/loader:1207:32)
#0 2.037     at Module._load (node:internal/modules/cjs/loader:1023:12)
#0 2.037     at Module.require (node:internal/modules/cjs/loader:1235:19)
#0 2.037     at require (node:internal/modules/helpers:176:18)
#0 2.037     at Object.<anonymous> (/app/node_modules/libsql/index.js:42:5)
#0 2.037     at Module._compile (node:internal/modules/cjs/loader:1376:14)
#0 2.037     at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
#0 2.037     at Module.load (node:internal/modules/cjs/loader:1207:32)
#0 2.037     at Module._load (node:internal/modules/cjs/loader:1023:12) {
#0 2.037   code: 'ERR_DLOPEN_FAILED'
#0 2.037 }
#0 2.037
#0 2.037 Node.js v20.11.1

Thanks for looking into this, @lovell! Unfortunately, the @neon-rs/cli bump was not related to the problem. Instead it’s this libsql issue related to the new encryption feature: https://github.com/tursodatabase/libsql/issues/1155