Probably is a newbie question but I'm ussing SST a...
# sst
e
Probably is a newbie question but I'm ussing SST along with Prisma and PlanetScale to build an API. So far everything is working fine locally. However after running deploy and hitting the API in prod, I'm getting this error :
021-09-30T15:29:23.784Z	a0688053-70ec-41c5-a480-13b3218dad0a	ERROR	Invoke Error
{ "errorType": "Error", "errorMessage": "ENOENT: no such file or directory, open '/var/task/src/schema.prisma'", "code": "ENOENT", "errno": -2, "syscall": "open", "path": "/var/task/src/schema.prisma", "clientVersion": "3.1.1", "stack": [ "Error: ENOENT: no such file or directory, open '/var/task/src/schema.prisma'", " at Object.openSync (fs.js:462:3)", " at Object.readFileSync (fs.js:364:35)", " at new LibraryEngine (/var/task/src/list.js:28474:46)", " at PrismaClient2.getEngine (/var/task/src/list.js:40879:20)", " at new PrismaClient (/var/task/src/list.js:40848:33)", " at Function.getClient (/var/task/src/list.js:41844:12)", " at Runtime.main [as handler] (/var/task/src/list.js:41853:17)", " at Runtime.handleOnce (/var/runtime/Runtime.js:66:25)" ] }
Since then I've read here that Prisma needs a Lambda layer for it to work properly. So I'm assuming that could be causing that error. But even looking at various snippets mentioned on this Slack I haven't managed to get the layer to build (getting some error 'execSync' is not defined, etc...). Is there a working sample or step by step guide I could look at ?
BTW the error mentions /var/task/src/schema.prisma not being found. In my project the schema is in prisma/schema.prisma. If that helps....
g
Have you checked examples/prisma ?
e
Wow, I can't imagine I didn't find that ! Let me go through it and see if that addresses my issues.
So I integrated the layer from that sample you pointed me to @Gabriel Bleu . it continues working fine locally. When I try to deploy I get a deployment failure after multiple minutes on the "Deploying Stacks" step with the following output :
[0%] start: Publishing 6b7303f81eec72729857154f23a3295242b95f0676f209560b879351f9949a6c:current
[16%] fail: write EPIPE
[16%] start: Publishing 501f948064d1523eeae05fe9bd1f16a6a244f436eca323d2aa5773d30e945cd3:current
[33%] success: Published 501f948064d1523eeae05fe9bd1f16a6a244f436eca323d2aa5773d30e945cd3:current
[33%] start: Publishing b071b8fd9f7b557cef62bd99954421421780a48cf6a5126e050621e11a733cb7:current
[50%] success: Published b071b8fd9f7b557cef62bd99954421421780a48cf6a5126e050621e11a733cb7:current
[50%] start: Publishing 3076728d5709698c4693419614fcc3b70e19e78c3156b3febb7ba7419273b4dd:current
[66%] success: Published 3076728d5709698c4693419614fcc3b70e19e78c3156b3febb7ba7419273b4dd:current
[66%] start: Publishing bb5f9c40a79ab818be34d336134e08ced1f45488e25992813b3932718317becc:current
[83%] success: Published bb5f9c40a79ab818be34d336134e08ced1f45488e25992813b3932718317becc:current
[83%] start: Publishing 3545e5a043c381cfa9679414dfdc03e68c9f4ab3752c48f3c310453da4baf80a:current
[100%] success: Published 3545e5a043c381cfa9679414dfdc03e68c9f4ab3752c48f3c310453da4baf80a:current
I looked into that first asset and it matches the Prisma one in the .build configuration....
Could slow connectivity (I'm on a 4G connection wihtout a great upload speed) be an issue when deploying ?
FYI, I have tried twice already, and trying again....
So it must have been a connectivity issue as after retrying once again it worked. But now I have a new issue when calling the deployed API : Environment variable not found: DATABASE_URL. That variable is set in my .env file at the root of my project. Is that getting deployed properly as well ? Anything I should do for that ?
f
Hey @Erik Robertson, env vars in your
.env
are only available at build time. You can set them as Lambda env vars like this https://docs.serverless-stack.com/environment-variables#environment-variables-in-lambda-functions
e
That's exactly what I was looking at, thanks for the pointer ! And guess what once I fixed that, all worked good so thanks to both you and @Gabriel Bleu. I hope this will help others in the future having similar issues.