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

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

Closed
RyanHedges opened this issue Dec 13, 2022 · 5 comments
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. tech/engines Issue for tech Engines. topic: openssl

Comments

@RyanHedges
Copy link

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
@RyanHedges RyanHedges added the kind/bug A reported bug. label Dec 13, 2022
@jirayui
Copy link

jirayui commented Dec 13, 2022

relates to this issue

#16553

@RyanHedges
Copy link
Author

Feel free to close as a duplicate if needed. Thanks!

@Druue Druue added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. tech/engines Issue for tech Engines. team/client Issue for team Client. topic: openssl labels Dec 13, 2022
@yusufbasol
Copy link

#14073 (comment)

@jkomyno
Copy link
Contributor

jkomyno commented Dec 14, 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)

@jkomyno jkomyno closed this as completed Dec 14, 2022
@jkomyno
Copy link
Contributor

jkomyno commented Dec 15, 2022

The solution with additional context was posted in #16553 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. tech/engines Issue for tech Engines. topic: openssl
Projects
None yet
Development

No branches or pull requests

5 participants