Error decoding lambda response error

Hello,

I recently went from Vercel to Netlify, and while everything works fine at Vercel, the site doesn’t work now with Netlify. I get the following error:

error decoding lambda response: error decoding lambda response: unexpected end of JSON input.

On trying loading the site, I see these lines in the “Function server handler” logs:

Jan 25, 09:05:40 AM: ERROR  Uncaught Exception 	{"errorType":"Error","errorMessage":"EMFILE: too many open files, open '/var/task/.netlify/functions-internal/server/node_modules/date-fns/lastDayOfWeek.js'","code":"EMFILE","errno":-24,"syscall":"open","path":"/var/task/.netlify/functions-internal/server/node_modules/date-fns/lastDayOfWeek.js","stack":["Error: EMFILE: too many open files, open '/var/task/.netlify/functions-internal/server/node_modules/date-fns/lastDayOfWeek.js'"]}
Jan 25, 09:05:40 AM: INIT_REPORT Init Duration: 2824.94 ms	Phase: invoke	Status: error	Error Type: Runtime.Unknown
Jan 25, 09:05:40 AM: Unknown application error occurred
Runtime.Unknown
Jan 25, 09:05:40 AM: a1f7b274 Duration: 3258.38 ms	Memory Usage: 119 MB
Jan 25, 09:06:38 AM: ERROR  Uncaught Exception 	{"errorType":"Error","errorMessage":"EMFILE: too many open files, open '/var/task/.netlify/functions-internal/server/node_modules/cmdk/dist/chunk-NZJY6EH4.mjs'","code":"EMFILE","errno":-24,"syscall":"open","path":"/var/task/.netlify/functions-internal/server/node_modules/cmdk/dist/chunk-NZJY6EH4.mjs","stack":["Error: EMFILE: too many open files, open '/var/task/.netlify/functions-internal/server/node_modules/cmdk/dist/chunk-NZJY6EH4.mjs'"]}
Jan 25, 09:06:39 AM: INIT_REPORT Init Duration: 2884.09 ms	Phase: invoke	Status: error	Error Type: Runtime.Unknown
Jan 25, 09:06:40 AM: Unknown application error occurred
Runtime.Unknown
Jan 25, 09:06:40 AM: c19db2d9 Duration: 3487.99 ms	Memory Usage: 121 MB

How can I troubleshoot this? :slight_smile:

The error means that too many files were opened at the same time. I believe Lambda has a limit of 1000 files. As to whhy your code is doing that, that’s not something we can troubleshoot, unfortunately.

I’ve noticed others have fixed this issue using code that either wasn’t compatible with Netlify or wasn’t implemented correctly. I’ve tested the exact same code on Vercel, Azure, and a locally configured setup, and it works perfectly on all of them—except Netlify.

For context, my project has 92 files in total, and I’m using Tanstack Start as framework.

What am I doing wrong?

you are not alone! i’m consistently getting this same error - only on netlify

Alright, not happy that you got the errors, but I am happy that I’m not alone in this.

What did you find out and how did you fix the errors?