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

Query engine binary not found in NextJS with custom output #2299

Closed
emckay opened this issue Apr 25, 2020 · 2 comments
Closed

Query engine binary not found in NextJS with custom output #2299

emckay opened this issue Apr 25, 2020 · 2 comments
Assignees
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. tech/typescript Issue for tech TypeScript.
Milestone

Comments

@emckay
Copy link

emckay commented Apr 25, 2020

Bug description

When specifying a custom output in prisma.schema

generator client {
  provider      = "prisma-client-js"
  output        = "generated/client"
  binaryTargets = ["native", "debian-openssl-1.1.x"]
}

Prisma client is unable to find the query engine binary when used in a NextJS server-side function. It is looking for the binary in the root of my filesystem (!) instead of in the generated prisma client directory.

Invalid `prisma.event.findMany()` invocation in
/home/.../.next/server/static/development/pages/index.js:317:45

  313 };
  314 
  315 const getStaticProps = async context => {
  316   const prisma = new _prisma_generated_client__WEBPACK_IMPORTED_MODULE_3__["PrismaClient"]();
→ 317   const featuredEvents = await prisma.event.findMany(Query engine binary for current platform "debian-openssl-1.1.x" could not be found.
This probably happens, because you built Prisma Client on a different platform.
(Prisma Client looked in "/query-engine-debian-openssl-1.1.x")

Files in /:

  bin
  boot
  cdrom
  dev
  etc
  home
  ...

You already added the platforms "native", "debian-openssl-1.1.x" to the "generator" block
in the "schema.prisma" file as described in https://pris.ly/d/client-generator,
but something went wrong. That's suboptimal.

If I remove the custom output directory and import from @prisma/client, everything works as expected.

I suspect this is due to webpack resolving __dirname to / (see: webpack/webpack#1599)

How to reproduce

I can probably put together a full repro if needed, but at a high level:

  1. Create new NextJS project
  2. Add prisma with custom output directory
  3. Write prisma query in getStaticProps or getServerSideProps after importing PrismaClient from custom output directory
  4. Note error when page renders
  5. Remove custom output directory and run prisma generate
  6. Change import to import {PrismaClient} from '@prisma/client
  7. Note there is no longer an error

Expected behavior

Expect to be able to import from my custom output directory

Prisma information

generator client {
  provider      = "prisma-client-js"
  output        = "generated/client"
  binaryTargets = ["native", "debian-openssl-1.1.x"]
}

Environment & setup

  • OS: Ubuntu
  • Database: PostgreSQL
  • Prisma version: 2.0.0-beta.3
  • Node.js version: v12.16.2
@pantharshit00
Copy link
Contributor

This is a known issue. See #2195

Explanation for this can be found here: #2195 (comment)

As, we have labelled that one as a question I am going to keep this open as the other issue is kinda specific to blitz framework.

@pantharshit00 pantharshit00 added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. process/candidate labels Apr 28, 2020
@janpio janpio added the tech/typescript Issue for tech TypeScript. label Apr 30, 2020
@divyenduz divyenduz added this to the Beta 5 milestone Apr 30, 2020
@janpio janpio modified the milestones: Beta 5, Beta 6 May 12, 2020
@janpio janpio modified the milestones: Beta 6, Beta 7, Beta 8 May 26, 2020
@timsuchanek timsuchanek self-assigned this Jun 4, 2020
@pantharshit00
Copy link
Contributor

Closing as outdated. This was resolved.

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. tech/typescript Issue for tech TypeScript.
Projects
None yet
Development

No branches or pull requests

5 participants