question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: suppressUnhandledRejections return promise instance

See original GitHub issue

(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.x

  1. What platform and version? (For example Node.js 0.12 or Google Chrome 32)

all

  1. Did this issue happen with earlier version of bluebird?

N/A (feature request)

(Write description of your issue here, stack traces from errors and code that reproduces the issue are helpful)

I would like to suggest an API change (semver major) to have .suppressUnhandledRejections() return the existing promise instance, allowing chained calls such as:

return Bluebird.reject(new Error('ouch')).suppressUnhandledRejections()

This is a pattern I use a lot in my unit tests where I want to prepare a rejection, then run the code under test, inject the rejected promise into the code path via mock/stub (sinon, testdouble, etc), then the code under test attaches its rejection handlers, and finally the test code path completes. Currently I need a separate helper method to avoid bluebird printing errors about potentially unhandled rejections.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7

github_iconTop GitHub Comments

1reaction
spioncommented, May 16, 2016

The problem with this suggestion is that you might get warnings in dev/prod that you did not get in tests. If you actually do have an error in the function which causes a warning to be generated, using the suppression feature this way in the test doubles will turn that warning off during testing - which is probably not what you want.

The suggestion itself seems okay, just not sure about the use case…

0reactions
focusauruscommented, May 16, 2016

Great! I verified .thenDo(() => Bluebird.reject(down)) seems to work with no warnings. Thanks! Leave this open for discussion as this fact seems unrelated to the feature request here, but my immediate needs are solved so feel free to close this if no one else thinks it would be useful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

feature request: ability to return a promise from add #713
Imagine you are setting up a redux container component with data from async action creators--well, then you need support for promises and async/await...
Read more >
suppressUnhandledRejections - Bluebird JS
Example : var tweets = fetchTweets(); $(document).on("ready", ... fetchTweets() .finally(function() { return $.ready.promise(); }) // DOM guaranteed to be ...
Read more >
promise-toolbox - npm
This library provides an implementation of CancelToken from the cancelable promises specification. A cancel token is an object which can be ...
Read more >
PromiseRejectionEvent.promise - Web APIs | MDN
This example listens for unhandled promises and, if the reason is an object with a code field containing the text "Module not ready", ......
Read more >
Promise-toolbox - npm.io
Asynchronous handlers are executed on token cancelation and the promise returned by the cancel function will wait for all handlers to settle.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found