question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UnhandledPromiseRejectionWarning

See original GitHub issue

Not sure if this is the lib error, or my code.

Express controller code:

router.get('/', (req, res, next) => {
  return req.prismic.api
    .query('')
    .then((posts) => {
      res.render('blog/index', {
        title: 'Blog',
        posts: posts
      })
    })
    .catch(next)
})

Now, disable connection on the computer and try to access the route:

(node:8251) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): FetchError: request to http://foo.prismic.io/api?access_token=… failed, reason: getaddrinfo ENOTFOUND foo.prismic.io foo.prismic.io:80

(node:8251) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
srenaultcommented, Oct 18, 2017

Hi, I’m going to look at it.

0reactions
BramDecuyperecommented, Oct 4, 2019

I still get these sometimes, and don’t really have an idea on how to fix them. Build a simple script that loops over and does a request to get some data…

https://github.com/BramDecuypere/loop-over-requests

Just keep running it multiple times and you will get either of 2 responses:

  • 429 --> logically, your service gets tired of my requests, which I understand after this amount
  • ENOTFOUND --> I have no clue what these are doing here? Is it something that is happening inside of node/node-fetch? Is it my code? Or the prismic service?

Just run the linked repo in 2 seperate terminals at the same time. And one of them will get this issue. Any insights would be great!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting a UnhandledPromiseRejectionWarning when testing ...
On the console I'm getting an 'UnhandledPromiseRejectionWarning' even though the reject function is getting called since it instantly shows ...
Read more >
What is UnhandledPromiseRejectionWarning
The Promise.reject() method returns a Promise object that is rejected with a given reason. The unhandledrejection event is sent to the global scope...
Read more >
Fixing UnhandledPromiseRejectionWarning in Node.js
If we fail to handle a Promise rejection, we're shown the UnhandledPromiseRejectionWarning by Node.js. const slowAndSteady = new Promise( ...
Read more >
Unhandled Promise Rejections in Node.js - The Code Barbarian
If you want to suppress the unhandled promise rejection warning, all you need to do is call .catch() on the promise with an...
Read more >
Unhandled Promise Rejection Warning - Codecademy Forums
I keep getting this error when I run my code UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found