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

when.reduce UnhandledPromiseRejectionWarning #492

Open
dkebler opened this issue Oct 27, 2016 · 4 comments
Open

when.reduce UnhandledPromiseRejectionWarning #492

dkebler opened this issue Oct 27, 2016 · 4 comments

Comments

@dkebler
Copy link

dkebler commented Oct 27, 2016

This is my when.reduce code

            return reduce(cmds, function(responses, cmd) {
                return processor(cmd).then(function(response) {
                    responses.push(response);
                    return responses;
                })
            }, [])

any rejection in processoror lower gets hung (unhandled) at when.reduce

(node:7520) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): manual rejection in processor**Command Processing Errors** manual rejection in processor

 (node:7520) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 2)

on the other hand...resolutions bubble up fine
FINAL response back [ 'manual resolution in processor' ]

to make sure it is when reduce I substituted this

return processor(cmds[0]);
and yes both resolutions and rejections bubble on through.

Is there an error in my construction of the reducer function or is this a bug?

Note I am using the latest version of nodejs 6.9.1 which since 6.0 now throws these warnings for any unhandled rejections

@dkebler
Copy link
Author

dkebler commented Oct 27, 2016

yes it's the when library... I switched to bluebird no warnings.

Seems like cujojs project is dead, many unclosed unresponded issues... :-(.

@briancavalier
Copy link
Member

Hi @dkebler. The messages you've reported are coming from Node's promise implementation, not from when.js. Here's what when.js's unhandled rejections look like.

I have no explanation for why Node is warning in this case. However, I have encountered a similar situation in another project, in a completely different context. most.js uses markdown-doctest to test the examples shown in all its documentation. As of Node 6.9.1, I get 4 warnings from Node's promise implementation when running the tests, and never got any before:

screen shot 2016-10-28 at 8 53 02 am

Note that markdown-doctest doesn't use when.js at all, and the format in that screenshot is the same as in your example.

So, I don't believe this is a when.js issue, but rather an issue introduced into Node 6.9.1.

@dkebler
Copy link
Author

dkebler commented Oct 31, 2016

This started coming up in my code and it happens when a rejection does not fully bubble up the chain. Until one finds and "fixes" them all the warning doesn't go away. For example if you have a returning promise inside another new one and you resolve inside the .then but add no .catch(e=>reject(e)) to the end you will get this warning. It's node's way of saying you have a "broken" chain issue. Like I said bluebird reduce does not throw this warning. I'd take a look rather than blame it on node. I can't use when if it throws this error because it causes my cli not to return to the prompt.

@mikaelkaron
Copy link

This is probably not related but I'll drop it here anyways (nodejs/node#821)

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

3 participants