How to debug inside .then() / How to confirm whether fetch.then() was run?

I have a problem where my code works fine locally but not when uploaded to netlify.

No error messages in:

  • netlify > function log > graphql (shows my proper debug output), no errors
  • devtools debug is fine/clean, no errors

The failing / not running part of my code is inside the .then() on functions like

  • fetch.then() which i had in a service
  • or db.user.create().then() which i have in a function

I also have .catch() but no output from there either.


  • Why does this work fine locally but not on netlify?
  • Do i have to do everything with await? Are the functions terminate before the promises/callbacks resolve?
  • Is there somekind of global node output on netlify?

Hey there,

Uncaught exceptions should be visible via the GraphQL response, could you share your deployed project’s URL with me so that I could take a look?

(You can DM it to me.)

1 Like

Thanks so much for helping. I’m curious to learn how to debug.

Public sample

+I gave you private access on github, you’ll probably die on the inside :wink: as I have the API key in there etc.

As above:

  • from the Homepage i call services/prices.js which triggers and update of prices.
  • This update i moved to api/src/functions/updatePricesForSymbol.js

But maybe now i have to await the db.price.create()?

1 Like

I followed the hunch to await everything, including doing for ... instead of .foreach( => )

after doing this it started working. I hope I don’t run into the 10s max runtime now :wink:

I still don’t know how to debug this mor.

Especially since it ran fine locally, but not deployed and i guess we always want to be as close to the deployment as possible.

That’s true - someone just opened an issue that mentioned serving a production build:

Since we’re deploying to lambda there are two things that might cause issues:

  1. A package that you’re relying on, on the api side, is using a dynamic import. This won’t work since Zip-it-and-ship-it (from netlify) bundles all the files together.
  2. That there’s some sort of runtime error - we’ll start thinking of a better way to get these exceptions and logs into a single place.