Skip to content

["native", "debian-openssl-3.0.x"] in prisma.schema only downloads "native" engine #23009

@mattgraphlan

Description

@mattgraphlan

Bug description

UPDATE: I was able to workaround this by putting the following in my github action. Without that, it would stop at "native" and only pick up debian-openssl-1.1.x,

env:
  PRISMA_CLI_BINARY_TARGETS: 'debian-openssl-3.0.x'

I'm having trouble making my github action build -> google cloud function work.

My prisma.schema file has the following:

generator client {
  provider      = "prisma-client-js"
  binaryTargets = ["native", "debian-openssl-3.0.x"] //  "debian-openssl-3.0.x" for google functions
}

However, after having the github action run prisma generate, there are no engine files present in the node_modules/@prisma/client folder, nor next to the prisma.schema file.

The two engine files that are available are in the node_modules/@prisma/engines folder, and only contain ["libquery_engine-debian-openssl-1.1.x.so.node","schema-engine-debian-openssl-1.1.x"], but is missing the "debian-openssl-3.0.x"

Oddly when I run openssl version in the github action, it gets 3.0.2 --- not sure why node_modules/@prisma/engines would only contain ["libquery_engine-debian-openssl-1.1.x.so.node","schema-engine-debian-openssl-1.1.x"] ?

  openssl version
  shell: /usr/bin/bash -e {0}
OpenSSL 3.0.2 15 Mar 2022 (Library: OpenSSL 3.0.2 15 Mar 2022)

I need to build the project on a different platform (github actions) than the run is happening (google cloud function), so it's very problematic that there's no "debian-openssl-3.0.x" engine downloaded.

Is there a way I can get this engine via the prisma CLI or soemthing, during my build step? I didn't see a way to do this in the prisma CLI, but maybe just missed it.

Have you tried to copy the engine in the suggested location? Did that work?

I can't, it's not available in the github action environment

Which package manager are you using?

Yarn

Is your workspace a monorepo setup?

Yes

Is your setup hosting multiple packages in a single workspace?

No, the google cloud function is not

Is a bundler in use? If yes, which one?

Yes, it's a custom one we wrote, so we can copy in the engine files ourselves... if they were the right version

Is a framework in use? If yes, which one?

Sort of... the google cloud "framework"

Your project uses TypeScript or just JavaScript?

Typescript

When you saw our message, did it happen locally or in deployment?

Deployment

Where is your project deployed?

  • Build: github action
  • Deploy / run: google cloud function gen2

Paste the error message

PrismaClientInitializationError: Prisma Client could not locate the Query Engine for runtime "debian-openssl-3.0.x".
This is likely caused by a bundler that has not copied "libquery_engine-debian-openssl-3.0.x.so.node" next to the resulting bundle.
Ensure that "libquery_engine-debian-openssl-3.0.x.so.node" has been copied next to the bundle or in "".
We would appreciate if you could take the time to share some information with us.
Please help us by answering a few questions: https://pris.ly/engine-not-found-bundler-investigation
The following locations have been searched:
  /workspace
  /
  /home/runner/work/REDACTED/REDACTED/node_modules/@prisma/client
  /.prisma/client
  /tmp/prisma-engines
    at ul (/workspace/index.js:85928:805)
    at async Object.loadLibrary (/workspace/index.js:85975:9937)
    at async qr.loadEngine (/workspace/index.js:85977:448)
    at async qr.instantiateLibrary (/workspace/index.js:85976:9762)

Error: Process exited with code 16
    at process.<anonymous> (/layers/google.nodejs.yarn/yarn_modules/node_modules/@google-cloud/functions-framework/build/src/invoker.js:92:22)
    at process.emit (node:events:517:28)
    at process.emit (node:domain:489:12)
    at process.exit (node:internal/process/per_thread:191:15)
    at sendCrashResponse (/layers/google.nodejs.yarn/yarn_modules/node_modules/@google-cloud/functions-framework/build/src/logger.js:44:9)
    at process.<anonymous> (/layers/google.nodejs.yarn/yarn_modules/node_modules/@google-cloud/functions-framework/build/src/invoker.js:88:44)
    at process.emit (node:events:517:28)
    at process.emit (node:domain:489:12)
    at emit (node:internal/process/promises:149:20)
    at processPromiseRejections (node:internal/process/promises:283:27)

How to reproduce

I'm not sure why my github action environment has openssl-1.1.x in it, but it would seem it does. I verified it also has openssl 3.0.2

yarn build-fns is what looks at and copies over the engines files that have been downloaded.

the relevant code is at:

  const PRISMA_ENGINES_DIR = 'node_modules/@prisma/engines';
  const prismaDir = path.resolve(__dirname, '../', PRISMA_ENGINES_DIR);
  const prismaFiles = await readdir(prismaDir);
  const engineFiles = prismaFiles.filter((file) => file.match(/engine/));

  console.log(
    'Copying ',
    engineFiles.length,
    'prisma engines to dist folder:',
    JSON.stringify(engineFiles),
  );

  console.log(
    'DEBUG: prismaDir has',
    prismaFiles.length,
    'files:',
    JSON.stringify(prismaFiles),
  );

Here's my github action template

  production-deploy:
    permissions:
      contents: 'read'
      id-token: 'write'
    runs-on: ubuntu-latest
    environment: production
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 'v18.18.2'
          cache: 'yarn'
      - name: Install dependencies
        run: |
          yarn global add node-gyp
          yarn install --frozen-lockfile
      - name: Verify OpenSSL Version
        run: openssl version
      - name: Generate Prisma
        run: yarn prisma generate
      - name: Build function
        env:
          NODE_OPTIONS: '--max_old_space_size=4096'
        run: yarn build-fns @MYREPO/${{ inputs.function }}

The rest of the template focuses on deployment to google cloud

Expected behavior

To also have the debian-openssl-3.0.x engine files on the system after prisma generate, instead of just debian-openssl-1.1.x

Prisma information

generator client {
  provider      = "prisma-client-js"
  binaryTargets = ["native", "debian-openssl-3.0.x"] //  "debian-openssl-3.0.x" for google functions
}

datasource db {
  provider = "mongodb"
  url      = env("DATABASE_URL")
}

models follow this in my prisma schema

Environment & setup

  • OS: ubuntu/debian
  • Database: MongoDB
  • Node.js version: 18

Prisma Version

{
    "@prisma/client": "5.9.1",
    "mongodb": "6.3.0",
    "prisma": "5.9.1"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions