Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Photon facade with netlify #324

Closed
divyenduz opened this issue Dec 9, 2019 · 11 comments
Closed

Photon facade with netlify #324

divyenduz opened this issue Dec 9, 2019 · 11 comments
Assignees
Milestone

Comments

@divyenduz
Copy link

divyenduz commented Dec 9, 2019

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.

@divyenduz divyenduz added bug/2-confirmed We have confirmed that this is a bug. kind/bug A reported bug. kind/regression A reported bug in functionality that used to work before. process/candidate Candidate for next Milestone. labels Dec 9, 2019
@divyenduz
Copy link
Author

Related issue: prisma/prisma#1015

@divyenduz
Copy link
Author

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

@janpio janpio removed the kind/bug A reported bug. label Dec 9, 2019
@kripod
Copy link
Contributor

kripod commented Dec 9, 2019

@divyenduz As for the size issue, zip-it-and-ship-it@v0.4.0-8 has a fix exclusively for prisma2.

@timsuchanek
Copy link
Contributor

I created an issue in zip-it-and-ship-it regarding the binary packaging. netlify/zip-it-and-ship-it#77

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

@kripod
Copy link
Contributor

kripod commented Dec 10, 2019

@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.

@timsuchanek timsuchanek removed bug/2-confirmed We have confirmed that this is a bug. kind/regression A reported bug in functionality that used to work before. labels Dec 11, 2019
@timsuchanek
Copy link
Contributor

@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.

@kripod
Copy link
Contributor

kripod commented Dec 11, 2019

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

@timsuchanek
Copy link
Contributor

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 ;)

@timsuchanek timsuchanek added this to the Preview 19 milestone Dec 11, 2019
@timsuchanek timsuchanek self-assigned this Dec 11, 2019
@janpio janpio removed the process/candidate Candidate for next Milestone. label Dec 18, 2019
@kokokenada
Copy link

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

@divyenduz
Copy link
Author

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

@divyenduz
Copy link
Author

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants