Lack of error context


  • netlify-site-name : “deploy-preview-8–”
  • Request ID : “1911bd8f-cf0f-4668-bcfe-58282ce9038c-1396183”

I’m having issues debugging on my deploy preview site. My netlify functions work (with netlify dev) locally but when I’m deploying, one functions throw a 500 error when being called in my Angular application without much context (sanitized log below) :

{"headers": {"normalizedNames": {},"lazyUpdate": null},"status": 500,"statusText": "Internal Server Error","url": "","ok": false,"name": "HttpErrorResponse","message": "Http failure response for 500 Internal Server Error","error": null}

I can’t find any logs in netlify admin panel. I’ve tried to setup Sentry to get more context but I don’t get more context as the error is not even reported in Sentry.

Is their any way to get more context on what is throwing this 500 error ?

Thanks a lot for your help !

After digging into netlify logs, it seems that the build step was causing this error.

More context, for the next one like me who will use typescript and make this mistake :

Here is my build step in my angular application (which trigger the netlify lambdas build too).

ng build --prod && npm ci --prefix netlify && npm run lambda:tsc && npm run nlb

It builds my Angular application, and install dependencies of my lambdas (I’ve got a specific package.json in my lambda for custom dependencies).

Then, I run typescript to convert my netlify lambda from typescript to pure JS so netlify can process them. Finally, I build the lambdas, which create X zip files, one for each lambda.

However, my mistake is that I still have the transpiled JS from typescript in the netlify lambdas folder during the upload of lambdas.

Which give this in the Netlify logs

2:07:29 PM: Packaging Functions from netlify/lambdas directory:
2:07:29 PM:  - aliases.js
2:07:29 PM:  -
2:07:29 PM:  - auth.js
2:07:29 PM:  -
2:07:29 PM:  - domains.js
2:07:29 PM:  -
2:07:29 PM:  - mailbox.js
2:07:29 PM:  -
2:07:29 PM:  - mailboxes.js
2:07:29 PM:  -
2:07:29 PM:  - mock.js
2:07:29 PM:  -
2:07:29 PM:  - providers/index.js

For some reasons, all lambdas worked fine (I don’t know if it is luck that picked up the .zip instead the .js file) but the “mailboxes” endpoint seems to use the “mailboxes.js” which was then missing its dependencies since they were in the zip.

Solution : a small script at the end of my build task that clean up this mess.

New task

"build": "ng build --prod && npm ci --prefix netlify && npm run lambda:tsc && npm run nlb && ./",

#!/usr/bin/env bash

cd netlify/lambdas || exit 1
find . ! -name "*.zip" -delete
cd - || exit 1

Hope it can help others ! :smile:

1 Like

awesome, thanks for sharing!