At Promise fromNode fromCallback - a promise was created but was not returned from it
mercteil opened this issue · 6 comments
(This issue tracker is only for bug reports or feature requests, if this is neither, please choose appropriate channel from http://bluebirdjs.com/docs/support.html)
Please answer the questions the best you can:
- What version of bluebird is the issue happening on?
- 3.7.2
- What platform and version? (For example Node.js 0.12 or Google Chrome 32)
- Node 12, Heroku worker
- Using babel 7
- Did this issue happen with earlier version of bluebird?
Locally there is no issue at all. I haven't known about this until I pushed to Heroku.
I am having this issue on Heroku:
2020-02-19T12:37:49.314100+00:00 app[worker.1]: (node:4) Warning: a promise was created in a handler at internal/process/task_queues.js:79:21 but was not returned from it, see http://goo.gl/rRqMUw
2020-02-19T12:37:49.314102+00:00 app[worker.1]: at Function.Promise.fromNode.Promise.fromCallback (/app/node_modules/bluebird/js/release/promise.js:206:9)
Since it is pointing to the bluebird node_module directly I assume there might be an issue in the package. (Btw. in the lib at the pointed fromNode.fromCallback there is this weird indentation of a ternary).
You have a promise somewhere you create in a .then
but forgot to return. Turn on long stack traces and figure it out :]
In general, please open support requests according to http://bluebirdjs.com/docs/support.html
I was just bitten by this, too. Basically, in BlueBird you're never allowed to have a Promise chain that ends in undefined
. A little annoying if you actually want to return undefined
from a Promise, but there we are. The documentation seems to suggest that you need to actually create a promise inside a handler for the warning to appear, but this does not appear to always be the case.
The documentation seems to suggest that you need to actually create a promise inside a handler for the warning to appear, but this does not appear to always be the case.
The test is literally that - if you don't create a promise inside and not return it creating a broken chain - no warning.
Based on reading the source, I would agree with you... Except that in this example the then
block clearly creates no promises, but when I removed the return null
at the end of it someone immediately raised an issue because they started seeing this warning:
Oh... I bet I know why. I bet the person who raised the issue was creating a Bluebird promise inside the connect
handler, which would be run synchronously from inside this block. Sneaky.
I suppose if you really wanted to create a Promise<void>
, you could return Promise.resolve()
(or return Promise.resolve(undefined)
).