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.

fetch() showing "a promise was created in a handler but was not returned from it" warning

See original GitHub issue

I am getting this warning:

a promise was created in a  handler but was not returned from it

For this code:

return new Promise((resolve, reject) => {
    return fetch(`${BASEURL}test/`)
    .then((response) => response.json())
    .then(resolve)
    .catch(reject);
});

Looking over the bluebird docs, I don’t understand why I’m getting this warning. My promise handler definitely returns a value. So why the warning?

P.S. You also have a double space in your warning message before the word ‘handler’.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:40 (11 by maintainers)

github_iconTop GitHub Comments

5reactions
whizkid77commented, Jun 23, 2016

For others who run into this issue (and are pretty sure they are returning from all handlers)

I am encountering same warning when wrapping Promise.resolve(fetch(…)). I cannot reproduce warning in isolation though. In majority of cases, it works just fine. The warning occurs when two fetch requests are being issued in quick succession. Putting second invocation of wrapped fetch into setTimeout clause avoids the warning. The warning seems to be emitted due to some racecondition, however I do not know enough bluebird internals to actually debug it…

Thanks @jesenko. I ran into the same issue where two fetch() calls are run in quick succession. Wrapping in setTimeout avoids the warning as well. I am using React Native’s fetch() polyfill.

I’d suggest reopening this issue…

4reactions
jonesnccommented, Jan 11, 2016

I’m getting this warning when using RxJS’s flatMap operator, but only in flatMap observers that are chained after the first flatMap observer is executed.

http://stackoverflow.com/questions/34728324/how-do-i-get-rid-of-a-bluebird-warning-when-chaining-more-than-one-flatmap-opera

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bluebird warning "A promise was created in a handler but was ...
First, try and update all your dependencies. There's been a recent version of Bluebird, which fixed an issue involving this warning.
Read more >
a promise was created in a handler at but was not returned ...
You created a promise here: Promise.all(CACHE.List .filter(shouldLoadFile) .map(file => Tutorials.get(file.id).then(content => { CACHE.
Read more >
Warning Explanations - Bluebird.js
Warning: a promise was created in a handler but was not returned from it. This usually means that you simply forgot a return...
Read more >
Using promises - JavaScript - MDN Web Docs
If the previous handler started a promise but did not return it, there's no way to track its settlement anymore, and the promise...
Read more >
Error handling with promises
The promise returned by fetch rejects when it's impossible to make a request. For instance, a remote server is not available, or the...
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