Middleware size is less than 1 MB still deployment failing

Continuing the discussion from The Edge Function "middleware" size is 1.01 MB and your plan size limit is 1 MB:

I checked the linked post but it didn’t solved my problem I am linking the post from next sub-reddit here, where I explained everything here

Currently deployment logs say The Edge Function "middleware" size is 1.01 MB and your plan size limit is 1 MB. but it was not the case in previous deployments so it should deploy without any erros

I can send the open sourced repo if needed.

Turbo repo:

  • Nextjs 14 (app)
  • Node/express (app)
  • Hono (app)
  • database (prisma)

I am using neon-adapeter to run prisma on serverless and I am not making any db calls in middleware instead I am just checking session and based on that re-routing user to a different route

additionaly, from the linked post whose solution is this documentation from prisma here can you explain the use case of this (runtime = edge) :

import { NextResponse } from 'next/server'
import { PrismaClient } from '@prisma/client'
import { PrismaNeon } from '@prisma/adapter-neon'
import { Pool } from '@neondatabase/serverless'

export const runtime = 'edge'

export async function GET(request: Request) {
  const neon = new Pool({ connectionString: process.env.DATABASE_URL })
  const adapter = new PrismaNeon(neon)
  const prisma = new PrismaClient({ adapter })

  const users = await prisma.user.findMany()

  return NextResponse.json(users, { status: 200 })
}

I have not used runtime = 'edge' in my code any where is this the problem?

Thanks!

If you’re having trouble deploying an Express app, this guide can help.

You can also ask v0 for suggestions tailored to your own project setup.

I don’t have a lot of context on your source code, although what is inside @/utils/apiRoute, @/lib/auth, and @/auth.config? Do they perhaps import large libraries?

If so, it would be best to split these files out to even more files, so the modules/files you need for the middleware do not import anything unnecessary, which could bloat your middleware file.

i have removed the part where we are checking session and it still giving me 1.01 MB as for what is inside what

  • apiRoute as name suggests is just routes hardcoded
  • auth is removed
  • auth.config is where user is logged in when he first enters website can be via OAuth or Email/pass

I am following this here from authjs.dev

as for what inside auth.config

@repo/db is where i am initializing my prisma, it was working before but from what i can think of after i started using neon-adapter i think that’s what cause all this.