fetch() showing "a promise was created in a handler but was not returned from it" warning
See original GitHub issueI 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:
- Created 8 years ago
- Comments:40 (11 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
For others who run into this issue (and are pretty sure they are
return
ing from all handlers)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’sfetch()
polyfill.I’d suggest reopening this issue…
I’m getting this warning when using RxJS’s
flatMap
operator, but only inflatMap
observers that are chained after the firstflatMap
observer is executed.http://stackoverflow.com/questions/34728324/how-do-i-get-rid-of-a-bluebird-warning-when-chaining-more-than-one-flatmap-opera