jasmine-promises icon indicating copy to clipboard operation
jasmine-promises copied to clipboard

Prevent UnhandledPromiseRejectionWarning in node 7

Open BenoitZugmeyer opened this issue 8 years ago • 3 comments
trafficstars

Starting from node 7, unhandled rejected promises are displaying a warning to the stdout: UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): ...

On top of that, a message telling that unhandled promise rejections will terminate the node process in the future.

The unhandled rejection occurs because the returnValue.then(...) statement returns a new rejected promise if the test is failing, but this returned promise isn't used.

This change makes promise resolution and rejection handling both at the same place, so no promise should be left unhandled.

Please note that although I didn't try, Chrome should behave in a similar way and print error messages in the console when a promise rejection is left unhandled. This patch fixes the problem there too.

BenoitZugmeyer avatar Feb 26 '17 19:02 BenoitZugmeyer

@BenoitZugmeyer this pull request has a broken build https://travis-ci.org/matthewjh/jasmine-promises/builds/205578527

agirorn avatar Apr 03 '17 10:04 agirorn

Yes, as far as I can see that's saucelab configuration issues, not related to my code. Tests are passing locally.

BenoitZugmeyer avatar Apr 03 '17 11:04 BenoitZugmeyer

@BenoitZugmeyer thanks. @matthewjh what it is needed to get this into master and released to https://www.npmjs.com/package/jasmine-promise? I'd really like to be able to use this module in node.js v4 and v6.

agirorn avatar Apr 04 '17 13:04 agirorn