lambdanext.jsserverless

Error: No more than 12 Serverless Functions can be added to a Deployment on the Hobby plan. Next js


What counts as a serverless function?

I had a website, https://contribute.meyabase.com/, which has been existing on Next Js for a while and recently while trying to deploy, I get the error

Error: No more than 12 Serverless Functions can be added to a Deployment on the Hobby plan. Create a team (Pro plan) to deploy more.

I don't use getStaticPaths/getServerSideProps or getIntitialProps. All I use is SWR. The only functions I have are auth0.com API routes (6 of them).

Below is the build logs

[21:26:55.979] Cloning github.com/axelmukwena/meyabase-contribute-client (Branch: main, Commit: 7cd2594)
[21:26:56.636] Cloning completed: 656.77ms
[21:26:59.495] Restored build cache
[21:26:59.537] Running "vercel build"
[21:27:00.000] Vercel CLI 28.13.0
[21:27:00.255] Warning: When using Next.js, it is recommended to place Node.js Serverless Functions inside of the `pages/api` (provided by Next.js) directory instead of `api` (provided by Vercel). Learn More: https://nextjs.org/docs/api-routes/introduction
[21:27:00.771] Installing dependencies...
[21:27:01.921] 
[21:27:01.921] up to date in 877ms
[21:27:01.921] 
[21:27:01.921] 102 packages are looking for funding
[21:27:01.921]   run `npm fund` for details
[21:27:01.933] Detected Next.js version: 13.0.3
[21:27:01.938] Detected `package-lock.json` generated by npm 7+...
[21:27:01.939] Running "npm run build"
[21:27:02.247] 
[21:27:02.247] > meyabase-contribute-client@0.1.0 build
[21:27:02.248] > next build
[21:27:02.248] 
[21:27:02.782] info  - Linting and checking validity of types...
[21:27:33.133] info  - Creating an optimized production build...
[21:28:27.861] info  - Compiled successfully
[21:28:27.861] info  - Collecting page data...
[21:28:34.338] info  - Generating static pages (0/35)
[21:28:34.607] info  - Generating static pages (8/35)
[21:28:34.847] info  - Generating static pages (17/35)
[21:28:35.011] info  - Generating static pages (26/35)
[21:28:35.200] info  - Generating static pages (35/35)
[21:28:35.250] info  - Finalizing page optimization...
[21:28:35.261] 
[21:28:35.280] Route (pages)                              Size     First Load JS
[21:28:35.280] ┌ ○ /                                      5.03 kB         379 kB
[21:28:35.280] ├   /_app                                  0 B             221 kB
[21:28:35.280] ├ ○ /[username]                            4.1 kB          396 kB
[21:28:35.280] ├ ○ /404                                   841 B           258 kB
[21:28:35.281] ├ ○ /500                                   775 B           258 kB
[21:28:35.281] ├ ○ /about                                 5.13 kB         335 kB
[21:28:35.281] ├ ○ /account                               1.91 kB         289 kB
[21:28:35.281] ├ ○ /admin                                 5.12 kB         373 kB
[21:28:35.281] ├ ○ /admin/articles                        5.31 kB         413 kB
[21:28:35.281] ├ ○ /admin/audio                           644 B           258 kB
[21:28:35.281] ├ ○ /admin/paragraphs                      4.37 kB         412 kB
[21:28:35.281] ├ ○ /admin/sentences                       5.11 kB         373 kB
[21:28:35.281] ├ ○ /admin/users                           6.83 kB         289 kB
[21:28:35.281] ├ λ /api/auth/[...auth0]                   0 B             221 kB
[21:28:35.281] ├ λ /api/auth/callback                     0 B             221 kB
[21:28:35.282] ├ λ /api/auth/login                        0 B             221 kB
[21:28:35.282] ├ λ /api/auth/logout                       0 B             221 kB
[21:28:35.282] ├ λ /api/auth/me                           0 B             221 kB
[21:28:35.282] ├ λ /api/auth/signup                       0 B             221 kB
[21:28:35.282] ├ ○ /articles                              1.53 kB         381 kB
[21:28:35.282] ├ ○ /articles/[articleSlug]                2.03 kB         373 kB
[21:28:35.282] ├ ○ /competition                           4.42 kB         334 kB
[21:28:35.282] ├ ○ /login                                 1.19 kB         233 kB
[21:28:35.282] ├ ○ /paragraphs                            5.75 kB         379 kB
[21:28:35.282] ├ ○ /paragraphs/[paragraphSlug]            2.79 kB         382 kB
[21:28:35.283] ├ ○ /privacy-policy                        5.93 kB         336 kB
[21:28:35.283] ├ ○ /rankings                              631 B           258 kB
[21:28:35.283] ├ ○ /recordings                            5.2 kB          373 kB
[21:28:35.283] ├ ○ /recordings/[recordingSlug]            2.65 kB         370 kB
[21:28:35.283] ├ ○ /reports                               4.45 kB         377 kB
[21:28:35.283] ├ ○ /reports/[reportSlug]                  3.55 kB         373 kB
[21:28:35.283] ├ ○ /search                                13.3 kB         383 kB
[21:28:35.283] ├ ○ /sentences                             698 B           258 kB
[21:28:35.284] ├ ○ /sentences/[sentenceSlug]              3.36 kB         385 kB
[21:28:35.284] ├ ○ /signup                                1.21 kB         233 kB
[21:28:35.284] ├ ○ /suggestions                           9.57 kB         303 kB
[21:28:35.284] ├ ○ /suggestions/[suggestionSlug]          4.65 kB         285 kB
[21:28:35.284] ├ ○ /terms-of-service                      7.56 kB         337 kB
[21:28:35.284] ├ ○ /translations                          4.82 kB         381 kB
[21:28:35.284] ├ ○ /translations/[translationSlug]        2.57 kB         372 kB
[21:28:35.284] ├ ○ /words                                 6.59 kB         378 kB
[21:28:35.284] └ ○ /words/[wordSlug]                      2.59 kB         370 kB
[21:28:35.284] + First Load JS shared by all              222 kB
[21:28:35.285]   ├ chunks/framework-05c5206d76924e06.js   45.7 kB
[21:28:35.285]   ├ chunks/main-1a2cd11733cdaa06.js        31.9 kB
[21:28:35.285]   ├ chunks/pages/_app-86a6c0b57a58efc3.js  142 kB
[21:28:35.285]   ├ chunks/webpack-8b448ac738e18d4a.js     1.37 kB
[21:28:35.285]   └ css/daa1d5f9bb57d053.css               690 B
[21:28:35.285] 
[21:28:35.285] λ  (Server)  server-side renders at runtime (uses getInitialProps or getServerSideProps)
[21:28:35.285] ○  (Static)  automatically rendered as static HTML (uses no initial props)
[21:28:35.285] 
[21:28:36.585] Traced Next.js server files in: 1.097s
[21:28:37.694] Created all serverless functions in: 1.106s
[21:28:37.720] Collected static files (public/, static/, .next/static): 21.326ms
[21:28:37.959] Using TypeScript 4.7.4 (local user-provided)
[21:28:42.910] Using TypeScript 4.7.4 (local user-provided)
[21:28:45.281] Using TypeScript 4.7.4 (local user-provided)
[21:28:45.565] Using TypeScript 4.7.4 (local user-provided)
[21:28:45.712] Using TypeScript 4.7.4 (local user-provided)
[21:28:45.878] Using TypeScript 4.7.4 (local user-provided)
[21:28:46.049] Using TypeScript 4.7.4 (local user-provided)
[21:28:46.187] Using TypeScript 4.7.4 (local user-provided)
[21:28:46.341] Using TypeScript 4.7.4 (local user-provided)
[21:28:46.483] Using TypeScript 4.7.4 (local user-provided)
[21:28:46.633] Using TypeScript 4.7.4 (local user-provided)
[21:28:46.907] Using TypeScript 4.7.4 (local user-provided)
[21:28:46.997] Using TypeScript 4.7.4 (local user-provided)
[21:28:47.211] Build Completed in /vercel/output [2m]
[21:28:49.879] Error: No more than 12 Serverless Functions can be added to a Deployment on the Hobby plan. Create a team (Pro plan) to deploy more.

Solution

  • Although it doesn't have to do with Next.Js, I had the same experience with another kind of application I'm developing. At first I thought it might be the number of endpoints my Python application has with FastAPI, but according to a comment I read on a forum "Every route you declared in the vercel.json file is a serverless function". This means what I declared in "builds":[{"src": "src/*.py"}]. In my case the number of .py files increased from a few to more than 12, but actually my API is concentrated in a single index.py file, in which all endpoints are declared. The solution was to change "builds":[{"src": "src/index.py"}] (without the *.py wildcard). In other words, each .py file was taken as a function.