Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

At Promise fromNode fromCallback - a promise was created but was not returned from it #1638

Open
mercteil opened this issue Feb 19, 2020 · 6 comments

Comments

@mercteil
Copy link

(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:

  1. What version of bluebird is the issue happening on?
  • 3.7.2
  1. What platform and version? (For example Node.js 0.12 or Google Chrome 32)
  • Node 12, Heroku worker
  • Using babel 7
  1. 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).

image

@benjamingr
Copy link
Collaborator

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

@jwalton
Copy link

jwalton commented Aug 25, 2021

See also: https://github.com/petkaantonov/bluebird/blob/808fdf8fce0cf4dbb1b95129607777a0cd53df36/docs/docs/warning-explanations.md#warning-a-promise-was-created-in-a-handler-but-was-not-returned-from-it

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.

@benjamingr
Copy link
Collaborator

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.

@jwalton
Copy link

jwalton commented Aug 26, 2021

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:

https://github.com/jwalton/node-amqp-connection-manager/blob/5038376ade39f2696a85552db786494d42ea98a2/src/AmqpConnectionManager.ts#L346-L380

@jwalton
Copy link

jwalton commented Aug 26, 2021

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.

@bergus
Copy link
Contributor

bergus commented Aug 26, 2021

I suppose if you really wanted to create a Promise<void>, you could return Promise.resolve() (or return Promise.resolve(undefined)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants