question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to establish a connection to query-engine-node-api library using node:16-alpine3.17

See original GitHub issue

Bug description

When using docker image node:16-alpine3.17 npx prisma generate encounters the following error in my bitbucket pipeline…

> npx prisma generate
Prisma schema loaded from prisma/schema.prisma
Error: Unable to establish a connection to query-engine-node-api library. It seems there is a problem with your OpenSSL installation!
Details: Unable to require(`/opt/atlassian/pipelines/agent/build/node_modules/prisma/libquery_engine-linux-musl.so.node`)
 Error loading shared library libssl.so.1.1: No such file or directory (needed by /opt/atlassian/pipelines/agent/build/node_modules/prisma/libquery_engine-linux-musl.so.node)
[Context: getDmmf]
Prisma CLI Version : 4.7.1

when viewing the build information that bitbucket pipeline provides I see this docker image information.

Images used:
    build : docker.io/library/node@sha256:b66869a9dc6bfeed416395c2a2f717bd1779af1cef828fe7941af3a8d0837fdc

I’ve been able to get around the current issue by specifying node:16-alpine3.16 as that was my last working version.

My current hypothesis is that there is an issue using openssl 3.0 because alpine3.17 makes it the default…

OpenSSL 3.0 is now the default OpenSSL version. OpenSSL 1.1 is available via the openssl1.1-compat package.

I believe I’m seeing this now because I previously had node:16-alpine as my defined docker image in my bitbucket-pipeline.yml, and the tag was changed today to point to alpine3.17

I’m not familiar with the prisma codebase but I did see that there is a parser function that the tests indicate some sort of matching. Perhaps that’s not operating correctly in this case?

Also note that I use linux-musl in my prisma.schema generator and maybe that’s also part of the problem as well?

Thanks for your input!

How to reproduce

For the problem

  1. Use a node docker image node:16-alpine or node:16-alpine3.17
  2. run npx prisma generate in the image
  3. See the error output

For a work around

  1. Use a node docker image node:16-alpine3.16
  2. run npx prisma generate in the image
  3. See generate successfully

Expected behavior

When using node:16-alpine3.17 docker image and running npx prisma generate in the image I expect to see a successful client generation like the following…

> npx prisma generate
Prisma schema loaded from prisma/schema.prisma
✔ Generated Prisma Client (4.7.1 | library) to ./node_modules/@prisma/client in 223ms
You can now start using Prisma Client in your code. Reference: https://pris.ly/d/client

import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()

Prisma information

generator client {
  provider      = "prisma-client-js"
  binaryTargets = ["native", "linux-musl"]
}

datasource db {
  provider = "postgresql"
  url      = env("PRIMARY_DATABASE_URL")
}

model Foo {
\\ model info
}
  constructor(configService: ConfigService<Env>) {
    this.primary = new PrismaClient();
    const replicaUrl =
      configService.get(EnvVariables.REPLICA_DATABASE_URL, { infer: true }) ??
      '';
    this.replica = new PrismaClient({
      datasources: { db: { url: replicaUrl } },
    });
  }

Environment & setup

  • OS: alpine3.17
  • Database: PostgreSQL
  • Node.js version: 16.18.1

Prisma Version

My local version, but the problem is seen in a docker image

npx prisma -v
Environment variables loaded from .env
prisma                  : 4.7.1
@prisma/client          : 4.7.1
Current platform        : darwin-arm64
Query Engine (Node-API) : libquery-engine 272861e07ab64f234d3ffc4094e32bd61775599c (at node_modules/@prisma/engines/libquery_engine-darwin-arm64.dylib.node)
Migration Engine        : migration-engine-cli 272861e07ab64f234d3ffc4094e32bd61775599c (at node_modules/@prisma/engines/migration-engine-darwin-arm64)
Introspection Engine    : introspection-core 272861e07ab64f234d3ffc4094e32bd61775599c (at node_modules/@prisma/engines/introspection-engine-darwin-arm64)
Format Binary           : prisma-fmt 272861e07ab64f234d3ffc4094e32bd61775599c (at node_modules/@prisma/engines/prisma-fmt-darwin-arm64)
Format Wasm             : @prisma/prisma-fmt-wasm 4.7.1-1.272861e07ab64f234d3ffc4094e32bd61775599c
Default Engines Hash    : 272861e07ab64f234d3ffc4094e32bd61775599c
Studio                  : 0.477.0

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jkomynocommented, Dec 15, 2022

The solution with additional context was posted in https://github.com/prisma/prisma/issues/16553#issuecomment-1353302617

1reaction
jkomynocommented, Dec 15, 2022

Hi @RyanHedges, closing this is a duplicate of #16553. Thanks for the details you’ve reported, we confirm that the Docker image for node:alpine was upgraded from using Alpine:3.16 (which used openssl 1.1) to Alpine:3.17 (which used openssl 3).

We’re working on a solution, for the time being you could install openssl1.1-compat when running Prisma on Linux Alpine 3.17+ (apk add openssl1.1-compat)

Read more comments on GitHub >

github_iconTop Results From Across the Web

redis - Official Image
Redis is an open source key-value store that functions as a data structure server.
Read more >
Dockerize NextJS Application with Prisma
I've found the error. I think it's a problem with the M1 Chip. I changed node:16-alpine3.12 to node:lts and added some commands to...
Read more >
Docker-machine Preparation Failed (#26564) - gitlab-runner
ERROR: Preparation failed: adding cache volume: set volume permissions: ... [0KUsing Docker executor with image node:16-alpine3.15@sha256: ...
Read more >
[Solved]-Dockerize NextJS Application with Prisma-docker
FROM node :17-slim as dependencies # set working directory WORKDIR ... to support Prisma query engine in Alpine Linux in final image RUN...
Read more >
Kubernetes | Programmatic Ponderings
Developing, testing, building, and deploying Native Quarkus-based Java microservices to Kubernetes on AWS, using GitOps ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found