Prisma-client-js: Photon facade with netlify

Created on 9 Dec 2019  Â·  11Comments  Â·  Source: prisma/prisma-client-js

Reproduction repository: https://github.com/divyendu-test/photonjs-324

Deploying a function with the following generator configuration on netlify fails with the following error

Config:

generator photon {
  provider = "photonjs"
}

Error:

Error: 
Invalid `photon.()` invocation in /var/task/hello-facade.js:8:37



Photon binary for current platform rhel-openssl-1.0.x could not be found.
Photon looked in null but couldn't find it.
Make sure to adjust the generator configuration in the schema.prisma file:
generator photon {
  provider      = "photonjs"
  binaryTargets = ["native"]
}
Please run prisma2 generate for your changes to take effect.
Note, that by providing `native`, Photon automatically resolves `rhel-openssl-1.0.x`.
Read more about deploying Photon: https://github.com/prisma/prisma2/blob/master/docs/core/generators/photonjs.md

Unique deployment link with this error: https://5dee48f3f80a08893213d0b7--p2-netlify-facade.netlify.com/.netlify/functions/hello-facade

Note: The suggestion in the error looks incomplete, when seen in production.


I changed it to the following config, ran prisma2 generate and re-deployed, to match the binary being detected by Photon:

Config:

generator photon {
  provider = "photonjs"
  binaryTargets = ["native", "rhel-openssl-1.0.x"]
}

But it still fails as if the binary is not there and the error message is a bit weird too, as it lists a thing that is already there.

Error:

Error: 
Invalid `photon.()` invocation in /var/task/hello-facade.js:8:37

Photon binary for current platform rhel-openssl-1.0.x could not be found.
Photon looked in null but couldn't find it.
Make sure to adjust the generator configuration in the schema.prisma file:
generator photon {
  provider      = "photonjs"
  binaryTargets = ["native", "rhel-openssl-1.0.x", "rhel-openssl-1.0.x"]
}
Please run prisma2 generate for your changes to take effect.
Note, that by providing `native`, Photon automatically resolves `rhel-openssl-1.0.x`.
Read more about deploying Photon: https://github.com/prisma/prisma2/blob/master/docs/core/generators/photonjs.md

Unique deployment link with this error: https://5dee4a45377315f699e946df--p2-netlify-facade.netlify.com/.netlify/functions/hello-facade

Note: All of this was with a global version of prisma2 CLI.


Trying it with a local version of prisma2 CLI now, same result.

Note that for both local, global CLI, it does list that it is downloading the listed rhel binary.

divyendusingh [p2-netlify]$ prisma2 generate
> Downloading Prisma engines for darwin and rhel-openssl-1.0.x [====================] 100%

Generating Photon.js to ./node_modules/@prisma/photon
Done in 1.78s

divyendusingh [p2-netlify]$ yarn prisma2 generate
yarn run v1.17.3
$ /Users/divyendusingh/Documents/prisma/p2-netlify/node_modules/.bin/prisma2 generate
> Downloading Prisma engines for darwin and rhel-openssl-1.0.x [====================] 100%

Generating Photon.js to ./node_modules/@prisma/photon
Done in 1.82s

✨  Done in 3.42s.

Most helpful comment

Interesting, good to know. The important message here is that it's fixed in the latest version of Netlifys build system anyway so I close this here :)

Now it's time to finally merge your PR ;)

All 11 comments

I have a hunch that zip-it-and-ship-it might be dropping the binaries because size or something.

@divyenduz As for the size issue, [email protected] has a fix exclusively for prisma2.

I created an issue in zip-it-and-ship-it regarding the binary packaging. https://github.com/netlify/zip-it-and-ship-it/issues/77

@kripod could you already get Photon.js running on Netlify? The current stable version is at least not working, but the beta might.

@timsuchanek Yes, please check out kripod/exigo. You may want to see the server directory and migrate to a remote SQL DB (replacing SQLite) to avoid hitting the read-only file system bottleneck on AWS Lambda.

@kripod are you part of the build beta? When using the build beta, it now works perfectly fine with the new version of zip-it-and-ship-it. However, the mechanism of pinning zip-it-and-ship-it as you did in exigo didn't work for me.

@timsuchanek Pinning the package version worked for me even before participating Build Beta.

Interesting, good to know. The important message here is that it's fixed in the latest version of Netlifys build system anyway so I close this here :)

Now it's time to finally merge your PR ;)

How do make it work Netlify?

I've added
"zip-it-and-ship-it": "netlify/zip-it-and-ship-it#v0.4.0-8"
to my package.json. That seems to install.

With binaryTargets = ["native", "rhel-openssl-1.0.x"] . I get

12:42:30 PM: Warning: Your current platform `debian-openssl-1.0.x` is not included in your generator's `binaryTargets` configuration ["rhel-openssl-1.0.x"]. 12:42:30 PM: To fix it, use this generator config in your schema.prisma: 12:42:30 PM: generator photon { 12:42:30 PM: provider = "photonjs" 12:42:30 PM: binaryTargets = ["native", "rhel-openssl-1.0.x"] 12:42:30 PM: } 12:42:30 PM: Note, that by providing `native`, Photon automatically resolves `debian-openssl-1.0.x`. 12:42:30 PM: Read more about deploying Photon: https://github.com/prisma/prisma2/blob/master/docs/core/generators/photonjs.md 12:42:32 PM: Generating Photon.js to ./src-graphql/generated/photon 12:42:44 PM: Error: Error: ENOENT: no such file or directory, copyfile '/opt/build/repo/node_modules/prisma2/query-engine-rhel-openssl-1.0.x' -> '/opt/build/repo/src-graphql/generated/photon/runtime/query-engine-rhel-openssl-1.0.x' 12:42:44 PM: npm

with binaryTargets = ["native", "debian-openssl-1.0.x"], I get:
12:35:58 PM: graphql-build.sh: running 'prisma2 generate' to generate database interface 12:36:01 PM: Generating Photon.js to ./src-graphql/generated/photon 12:36:13 PM: Error: Error: ENOENT: no such file or directory, copyfile '/opt/build/repo/node_modules/prisma2/query-engine-debian-openssl-1.0.x' -> '/opt/build/repo/src-graphql/generated/photon/runtime/query-engine-debian-openssl-1.0.x' 12:36:13 PM: npm 12:36:13 PM: ERR! code ELIFECYCLE

Note that it works with the GH integration but not with the netlify build command yet.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

divyenduz picture divyenduz  Â·  3Comments

divyenduz picture divyenduz  Â·  3Comments

maartenraes picture maartenraes  Â·  4Comments

Errorname picture Errorname  Â·  3Comments

MichalLytek picture MichalLytek  Â·  3Comments