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.

Detect if bluebird is used instead of native Promises

See original GitHub issue

Is there a way to automatically verify that my code uses bluebird promises instead of native ones? In other words I would like every file that uses Promise object to be checked if there is a var Promsie = require('bluebird'); in the beginning of the file.

If there is no such tool I will happily write one, when I have time that is:).

Edit I’m using Node v4 with ES6 and the way I’m using promises is polyfilling/replacing original Promise object with Bluebird one. It’s the same approach that Bluebird promotes in their documentation here.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
eteeselinkcommented, Oct 3, 2016

I think most people just use bluebird to replace the global Promise object and call it a day.

1reaction
jan-swieckicommented, Oct 2, 2016

@benjamingr so please modify Bluebird documentation. Currently Bluebird is encouraging usage of var Promise = require('bluebird'); which is a trap. By trap I mean situation whenever somebody forgets to import blurbird and by mistake original Promise object is used and application either breaks (easy to fix) or there are silent errors (impossible to fix, because you don’t even know that there is an error somewhere). As you may know original Promises don’t print errors that are thrown from within promise chain.

One of the reasons I use bluebird is that it prints uncaught errors to the console.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Native promises vs. Bluebird promises - node.js - Stack Overflow
Like with many things in Javascript, you should probably just test to see if the features you want to use are present rather...
Read more >
Using Bluebird Promises - Mastering JS
Bluebird is a popular promises library for JavaScript. It is a drop-in replacement for native Promises in JavaScript. global.
Read more >
Bluebird vs Native vs Async/Await - 2020 State of Javascript ...
Use Bluebird for parallel execution of promises. In general: Bluebird retains the smallest memory footprint in all cases; Promise performances ...
Read more >
Features - Bluebird JS
Synchronous inspection allows you to retrieve the fulfillment value of an already fulfilled promise or the rejection reason of an already rejected promise...
Read more >
Native vs 3rd Party Promise Implementations - Bambielli's Blog
It points to a perf test that shows Bluebird promises are around 4x faster and use 4x less memory than native ES6 promises...
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