All function endpoints reach timeout without reaching nextjs handler code

Site name: velvety-vacherin-4193fb
Netlify URL:

All netlify function endpoints for my PR deploy are reaching the 10s timeout without running any of the endpoint code. I’ve identified the offending commit ( before the commit, all endpoints work fine, after the commit, they reach timeout), but I’m having trouble identifying the issue. I added a console.log to the start of one Nextjs endpoint (/api/panel) and the netlify timeout is being hit without logging my console.log.

Link to example endpoint that hits timeout: tRPC.panel()
Code for example endpoint that hits timeout, here console.log is not being reached:
Timeout log (Netlify internal ID: 01HAABYK4KWMRFG89WQPJ5VKWW) (this is it - there’s no typical “INFO [GET] /api/…” logged):

Sep 14, 12:31:08 PM: 84a8da82 2023-09-14T17:31:19.511Z 84a8da82-f281-4635-b34a-fb7d6f7b488a Task timed out after 10.03 seconds
Sep 14, 12:31:18 PM: 84a8da82 Duration: 10034.46 ms Memory Usage: 296 MB Init Duration: 451.51 ms

Important notes:

  • I’ve read the functions official docs, support guide [Support Guide] Netlify Lambda Functions 101 & Debugging, and tried browsing a few forums posts
  • Functions build & deploy without issues (deploy log: Netlify App)
  • Same timeout happens for other api endpoints (e.g. /api/auth/login, /api/trpc/[…])
  • The endpoints with PR’s code work locally (via next dev), AND I’ve confirmed that endpoints with netlify dev ALSO work locally

I’m going to continue trying to investigate why my commit is causing the problem, but it’s entirely guess-and-check for me (add code, check if problem exists, remove code, check if problem exists), and I’ve spent several hours getting this far. Is there any way to have more details logged from before the request handler runs to help debug? I’m not sure how to more efficiently debug, since I’ve already tried adding a console.log to the beginning of the request handler, and that isn’t getting reached.

I’m still wondering if there would’ve been a better way to identify that there was an issue with the serverless function’s loading of dependencies. Better logging? Or could I have reproduced this locally somehow, with netlify dev? Would love to hear any suggestions.

I don’t think there’s any easy way to identify the issue in this case. netlify dev would simply run Next.js dev server locally, so you’d most likely not run into the same issue there. Logging could probably not help either as the code fails right at the imports which would very likely be the top lines in your code.

I personally happen to know MUI is a repetivite offender of this issue. But since I would not have known that you’re using that in your project, I’d probably not have suggested that.

All in all, this would have been a difficult case to debug without us checking your source code, which we usually don’t do.

1 Like