Next.js Discord

Discord Forum

Vercel Serverless Function is 50.61mb which exceeds the maximum size limit of 50mb!

Unanswered
Abyssinian posted this in #help-forum
Open in Discord
AbyssinianOP
I have a small webapp running NextJS 13, hosted on Vercel. I made a simple serverless function to receive a PDF, do some processing, and return a JSON. When I tried to deploy my app, I get the bellow failure message from Vercel. My file structure is

- app --- api ----- parse-pdf ------- route.ts --- page.tsx

route.ts contains my serverless function code and is only 1KB, so how is this error even possible? Can someone please help me understand? Thank you!

10 Replies

what packages does route.ts rely on?>?
and in general what packages do you rely on to do pdf processing?
AbyssinianOP
Ah I see, yes, I have
ts import { getDocument, PDFDocumentProxy } from 'pdfjs-dist';
in route.ts. I guess pdfjs-dist is too big of a library?
Update: it says here: https://www.npmjs.com/package/pdfjs-dist that the library is only 32.3 MB. The only other import I have in route.ts is
tsimport { NextResponse } from 'next/server';
. This is confusing.
Give t his a try
theres some other threads on the topic here too
Another solution