Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

This does not work with Prisma #81

Closed
divyenduz opened this issue Jan 24, 2020 · 10 comments
Closed

This does not work with Prisma #81

divyenduz opened this issue Jan 24, 2020 · 10 comments
Labels
bug Something isn't working

Comments

@divyenduz
Copy link

Describe the bug

The same project with GH integration works but doesn't work with netlify build and netlify deploy command combination.

Prisma client requires latest version of ZISI (ZISI_VERSION=0.4.0-8) as it contains this fix #77

Steps to reproduce

Reproduction repository https://github.com/divyenduz/netlify-ci-build
The repo readme has all the context and reproduction steps.

Expected behavior

GH integration and netlify build && netlify deploy should be identical.

Configuration

As mentioned in the reproduction repo's readme, both projects use netlify's beta build.

Environment

Enter the following command in a terminal and copy/paste its output:

divyendusingh [platforms]$ npx envinfo --system --binaries --npmPackages @netlify/build,@netlify/config,@netlify/git-utils,@netlify/cache-utils,@netlify/functions-utils,@netlify/run-utils,netlify-cli
npx: installed 1 in 1.265s

  System:
    OS: macOS 10.15.2
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
    Memory: 755.51 MB / 32.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.8.0 - ~/.nvm/versions/node/v12.8.0/bin/node
    Yarn: 1.21.1 - ~/.nvm/versions/node/v12.8.0/bin/yarn
    npm: 6.10.2 - ~/.nvm/versions/node/v12.8.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman

Screenshots

https://github.com/divyenduz/netlify-ci-build

Can you submit a pull request?

No. Because possibly internal code :)

@ehmicky
Copy link
Contributor

ehmicky commented Jan 24, 2020

Hi @divyenduz,

Thanks for reporting this issue.

@netlify/build is using the latest version of zip-it-and-ship-it, i.e. 0.4.0-8.

$ npm ls @netlify/zip-it-and-ship-it
 
netlify@1.0.0 /home/ether/Desktop/netlify-ci-build
└─┬ netlify-cli@2.30.0
  ├─┬ @netlify/build@0.1.46
  │ ├── @netlify/zip-it-and-ship-it@0.4.0-8 <-- Used by Netlify Build
  │ └─┬ netlify@3.0.0
  │   └── @netlify/zip-it-and-ship-it@0.3.1  <-- Used by Netlify JavaScript client
  ├── @netlify/zip-it-and-ship-it@0.3.1 <-- Used by Netlify CLI but not by Netlify Build
  └─┬ netlify@2.4.8
    └── @netlify/zip-it-and-ship-it@0.3.1  deduped

I cloned your repository, then ran Netlify Build locally. The functions are bundled in .netlify/functions/. The produced archive contains the functions. When extracting it, the functions seems to have correctly installed @prisma/client. For example, if I install @prisma/client directly in a separate directory, I get the same list of files than the ones in the function. From that perspective I don't think there is something wrong with Functions bundling on that end.

I don't know Prisma, so I might need some guidance here: in particular, I am curious about the fact that the error messages tries to find a file at node_modules/\@prisma/client/runtime/query-engine-rhel-openssl-1.0.x. However this file is not installed by npm install @prisma/client. I think Prisma might do some postinstall logic that might add those files. Do you have some additional information about this?

Also, thanks for the demo repository. Is there any chance you could reduce its size? If not, no worries, what matters is that it's reproducible :)

@ehmicky ehmicky transferred this issue from netlify/build Jan 24, 2020
@ehmicky ehmicky changed the title Use the latest ZISI with netlify build command (GH integration works) This does not work with Prisma Jan 24, 2020
@ehmicky ehmicky added the bug Something isn't working label Jan 24, 2020
@divyenduz
Copy link
Author

So, in my case, the binary files were present in the node_modules after the postinstall hook or prisma2 generate is run.

The green ones are the required binaries

image

They are also present in the bundled function (my original assumption about zip-it-and-ship it were wrong). I extracted the zip and could see them in the ls.

image

But at runtime, I get this error: Query engine binary for current platform rhel-openssl-1.0.x could not be found.\nPrisma Client looked in /var/task/node_modules/@prisma/client/runtime/query-engine-rhel-openssl-1.0.x

Which makes me believe, that the unzip + moving these files to /var/task/node_modules is missing copying the binaries.

Is there a way for me to test this and/or get more visibility into this? Could you validate this?

Note that the same codebase works with the GH integration of netlify. Are there any differences in the unzip logic between netlify deploy command vs the GH integration?


Also, thanks for the demo repository. Is there any chance you could reduce its size? If not, no worries, what matters is that it's reproducible :)

What do you mean by reducing its size?

@divyenduz
Copy link
Author

So, I went ahead and did some more logging (sh run.sh as the command in netlify.toml that logs the contents of the current directory), this is a snapshot from the GH integration CI (where it works).

image

I am not sure though what is the difference between this vs netlify build and deploy but at some point (my hunch is after unpacking) the binaries don't exist anymore.

@divyenduz
Copy link
Author

I also logged at runtime the following information: __dirname, ls, ls node_modules/@prisma/client/runtime | grep query-engine

and as I expected, there are no binaries in the case where it doesn't work (netlify build && netlify deploy --prod)

image

and the binaries exist in the case where it works (GH integration)

image


Interesting to note that the two deployment methods have different folder structure and __dirname. They should be identical right?

I hope this information helps you in helping us.

@heymartinadams
Copy link

heymartinadams commented Mar 27, 2020

@divyenduz running into the same issue when attempting a deploy:

"Error: 
Invalid `prisma.user.update()` invocation in
/var/runtime/Runtime.js:66:25

Query engine binary for current platform "rhel-openssl-1.0.x" could not be found.
This probably happens, because you built Prisma Client on a different platform.
(Prisma Client looked in "/query-engine-rhel-openssl-1.0.x")

You already added the platforms "native", "rhel-openssl-1.0.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.

Please create an issue at https://github.com/prisma/prisma-client-js/issues/new"

Meanwhile, my netlify.toml file contains the following. Might you know what I’m missing?

[build]
command = "yarn beta"
functions = "build-functions/"
publish = "build/"

[build.environment]
# Fix to ensure the Prisma binary is packaged with the lambda function
ZISI_VERSION = "0.4.0-9"

Using the latest Prisma CLI and client preview025 (released today).

  • my yarn beta package.json script runs the following:
"scripts": {
  "beta": "cd functions && yarn && cd .. && npx prisma2 generate && netlify-lambda build functions && netlify-lambda install functions && react-scripts build"
}

@heymartinadams
Copy link

ps: I should be saying that I’m using Github integration.

@divyenduz
Copy link
Author

Can you try to rename your command from beta to build?

@heymartinadams
Copy link

@divyenduz already opened up a new issue here.

@ehmicky
Copy link
Contributor

ehmicky commented Apr 17, 2020

Is this issue closed by this?
@divyenduz @timsuchanek

@divyenduz
Copy link
Author

I think so yes 🙌

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants