Middleware + prisma > 1 MB hobby size limit

Looks like we can no longer use latest prisma in our middleware as it will bump the output above the hobby plan’s 1 MB limit.

I unfortunately believe I need to include prisma in my middleware in order to properly handle credential based logins. Otherwise following Migrating to v5 would probably have worked.

This seems pretty bad, prisma is highly used and not being able to successfully use it within hobby plan will really surprise people (like myself) and prevent people from trying out vercel. Please help!

Related issues:

Error:

Error: The Edge Function "middleware" size is 1.17 MB and your plan size limit is 1 MB. Learn More: https://vercel.link/edge-function-size

Hey @wes-r. Prisma is very commonly used with the Hobby plan. It’s much more commonly used in Vercel Functions than in Middleware though.

The 1 MB code size limit on the free Hobby plan does limit the size of packages and other code files that can be used. However, there are other options to get it working in your project. For example:

  • Reduce the size of imports the minimum needed. Use a package size checker tool like bundle to check the size of a package and find a smaller alternative if possible.
  • Split up the work to minimize tasks being handled in Middleware and move what you can to other Functions.
  • Upgrade to a Pro plan to increase the middleware code size limit to 2 MB.

Hi @amyegan, thanks for the reply.

I’m semi new to the ecosystem. My understanding is that the Next/nex-auth middleware is run prior to other requests. This is often used for authentication/authorization which is where I find myself needing Prisma (to confirm user/pass). Maybe I have misunderstood how credential auth can be setup and how it ties into the Next middleware?

To reduce the middleware code size, you can use the split config strategy recommended in the Auth.js docs. That’s what I would do for a small project that didn’t need a Pro team.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.