0

So I am trying to figure out what part of my nodejs script is causing this warning to appear

UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 4)

The issue is that Node is not telling me what line this is being triggered at - So I don't know how to fix it.

And I would really like to fix it before it becomes a bigger problem.

Is there away to get NodeJS to put line number when a warning like this is triggered?

RussellHarrower
  • 6,470
  • 21
  • 102
  • 204
  • The problem is that nodejs doesn't know what line number caused the problem. It finds out after the fact that a promise rejected and there was no handler for that rejection. Usually, there is some context about what operation is involved and code inspection can identify possible culprits. – jfriend00 Oct 07 '20 at 01:01
  • https://stackoverflow.com/questions/43834559/how-to-find-which-promises-are-unhandled-in-node-js-unhandledpromiserejectionwar - This answer solved my issue – RussellHarrower Oct 07 '20 at 01:02
  • So, if you now have an answer to your question, then either delete your question or post an answer to your own question or mark it a duplicate of that other question. You shouldn't just leave it hanging out here with no answers if your problem is now solved. – jfriend00 Oct 07 '20 at 01:37
  • Refer to https://stackoverflow.com/questions/43834559/how-to-find-which-promises-are-unhandled-in-node-js-unhandledpromiserejectionwar – kennysliding Oct 07 '20 at 05:32

0 Answers0