prisma: @prisma/engines weights 113 MB and causes maximum size limit error on Vercel
Bug description
When I try to deploy a Next.js + GraphQL + Prisma application on Vercel I receive an error about exceeding the lambda function limit.
23:15:50.190 Max serverless function size of 50 MB compressed or 250 MB uncompressed hit
23:15:50.190 Serverless Function's page: api/graphql.js
23:15:50.191 Large Dependencies Uncompressed size Compressed size
23:15:50.191 node_modules/@prisma/engines 113 MB 39.6 MB
23:15:50.191 node_modules/.prisma/client 45.9 MB 16.1 MB
23:15:50.191 node_modules/prisma/build 5.27 MB 1.09 MB
Full log here: https://gist.github.com/talentlessguy/74f58664cd5af05407037be15b3b25a1
How to reproduce
- Create a new Next.js project with these files: https://gist.github.com/talentlessguy/9cac915be4fa6a1ea911c7f0ead5fa2b
Expected behavior
I expected a Next.js app to build and launch as it usually does (it did run fine 1-2 weeks ago)
Prisma information
Schema: https://gist.github.com/talentlessguy/9cac915be4fa6a1ea911c7f0ead5fa2b#file-graphql_schema-ts
Environment & setup
- OS: Vercel Linux runtime
- Database: PostgreSQL
- Node.js version: 14.16
- Prisma version: 2.22.0
prisma : 2.22.0
@prisma/client : 2.22.0
Current platform : debian-openssl-1.1.x
Query Engine : query-engine 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules/.pnpm/@prisma+engines@2.22.0-21.60cc71d884972ab4e897f0277c4b84383dddaf6c/node_modules/@prisma/engines/query-engine-debian-openssl-1.1.x)
Migration Engine : migration-engine-cli 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules/.pnpm/@prisma+engines@2.22.0-21.60cc71d884972ab4e897f0277c4b84383dddaf6c/node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine : introspection-core 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules/.pnpm/@prisma+engines@2.22.0-21.60cc71d884972ab4e897f0277c4b84383dddaf6c/node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary : prisma-fmt 60cc71d884972ab4e897f0277c4b84383dddaf6c (at node_modules/.pnpm/@prisma+engines@2.22.0-21.60cc71d884972ab4e897f0277c4b84383dddaf6c/node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Default Engines Hash : 60cc71d884972ab4e897f0277c4b84383dddaf6c
Studio : 0.379.0
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 3
- Comments: 44 (24 by maintainers)
Ok, so we figured out what is going on here and I need to document that for later:
2.22.0-dev.39and2.22.0-dev.40- and was shipped with2.22.0.nexus-plugin-prisma- which you are all using in your projects.2.23.0-dev, which will of course also be included in2.23.0.nexus-plugin-prismawhat triggered this bug in the CLI to become active.nexus-plugin-prismaled to Prisma Client Postinstall and via that Prisma CLI and via that Prisma studio was triggered: https://github.com/vercel/nft/issues/203#issuecomment-840541429nexus-plugin-prismacould break that inclusion: https://github.com/graphql-nexus/nexus-plugin-prisma/pull/1089/files Our reproduction project can successfully be published on Vercel when we change thenexus-plugin-prismadependency to that PR version: https://github.com/janpio/prisma-limit-repro/pull/11/filesCase closed. π
Left to do now is to maybe clean up
nexus-plugin-prismaa bit and certainly add our reproduction project (Thanks @talentlessguy again!!) to our e2e tests with the failing dependency versions, then update to recent ones to make sure the problems are gone and will never come back (in this one specific combination).Yes, now I have a reproduction that I can poke.
This will definitely land in production very soon so you can switch back to
latestof Prisma CLI and Client π (Expect it latertodaytomorrow.)Looks like itβs not an issue anymore? Iβm using Prisma 2.23 on an old project and it deploys fine
@janpio I am running into this error on 2.23 WITHOUT
nexus-plugin-prismaMy bundle size has increased a lot recently and I am not sure why. Vercel logs below with
NEXT_DEBUG_FUNCTION_SIZE=1I am using nx workspace with my prisma client in a lib. It worked fine until recent versions of prisma (2.20 if I recall). I temporarily fixed the issue on one PR by adding
N-APIpreview feature which reduced my function size slightly and got it from just over the 50mb limit to just below the 50mb limit, but in a newer PR where my code size increased I am back over the 50mb limit despite havingN-APIenabledNot sure if it has an effect, but I am using pnpm
Another data point here: I was facing the same issue, but by installing
@prisma/client@2.23.0-dev.9andprisma@2.23.0-dev.9it was fixed!Thanks for your great work for the community π π π
Make totally senseβ¦ so thatβs gonna be fun to find out π
They should be there - we could of course remove those dependencies or delete them to fix the problem right now - but that would not generally solve it. These files should just not be included by Vercel when they create that archive to upload it to AWS as they are not actually needed by the function. Exactly that is happening in our e2e test that is succeeding with Nextjs to Vercel. But not here, so some of the other code confuses Vercel.
Hey @janpio I canβt really share the project and thereβs a lot of bigger stuff there than prisma alone.
Iβll be off for a week, but Iβll do before upgrading.
Thanks a lot
PS: Iβm just preparing some things to have easier reproducible examples on a bigger starter (like https://github.com/belgattitude/nextjs-monorepo-example/pull/36).
Hey @belgattitude, can you maybe open a new issue for your function? I would like to look into that as well because of you getting pretty close. If you just include the informatio oyu posted here, I think we can start debugging this.
As we at Prisma have a Nextjs project deployed to Vercel in our end to end tests, to make sure nothing goes wrong when we release a new version (actually with each commit we build a
devversion that is run there), I know that this combination can result in a function of only 16MB - as it should:So it is probably one of the dependencies or configuration that @talentlessguy is using in his project (obvious candidate: webpack 5). I am currently looking into these one by one until I can pinpoint it.
Seems we will need to add another e2e test in the future to make sure this combination stays good (after we fix it of course).
You should only have that locally, but
@prisma/enginesshould not be included in the uploaded archive in the first place, as it is a dependency of a dev dependency,prismaCLI. Something seems to be messing with that detection for some reason.(That is also the reason why the file exists twice - the generated client needs to be self contained as you can also generate to another location via
outputin thegeneratorblock of your schema, and some people then publish that folder as an Npm package, upload it as an artifact or many similar things).So indeed, complex.
@janpio weβll probably be impacted as well in the futureβ¦ The binary size has slightly grow (80kb) but thereβs something Iβm wondering that could help.
Why do we have 2 times the
query-engine-debian-openssl-1.1.xin 2 different directories ?in ./node_modules/.prisma/client/
in ./node_modules/@prisma/engines
Could we get rid of one, or symlinking in a post install ?
@janpio ok, please wait a few minutes while Iβm bootrstraping a repo
FYI, it works fine with
prismaand@prisma/clientv2.21.2@janpio I deploy it using vercel github integration