when.reduce - reject chain breaks with unhandled rejection warning

31 views
Skip to first unread message

David Kebler

unread,
Oct 27, 2016, 2:23:27 AM10/27/16
to cujojs
This is my when.reduce code

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


any rejection in processor or 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
uCOMmandIt
> (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


David Kebler

unread,
Oct 27, 2016, 2:48:00 AM10/27/16
to cujojs
it's the when library, I switched to bluebird and it runs without warnings
Reply all
Reply to author
Forward
0 new messages