Inconsistent behavior of execution when using multiple copies of bluebird
See original GitHub issue- What version of bluebird is the issue happening on?
v3.5.1
- What platform and version? (For example Node.js 0.12 or Google Chrome 32)
Node.js 6.8.1
& Node.js 8.11.1
- Did this issue happen with earlier version of bluebird?
It also happens with bluebird v3.4.7
To replicate:
mkdir bluebird-test
cd bluebird-test
npm init --yes
npm i bluebird --save
cp -r ./node_modules/bluebird ./node_modules/bluebird2
touch index.js
- copy & paste the following into the
index.js
node index.js
const Promise = require('bluebird');
const Promise2 = require('bluebird2');
function second() {
console.log('SECOND');
}
function start() {
return new Promise(function(resolve, reject) {
process.nextTick(tick);
function tick() {
return setup().catch(function(err) {
console.log('FIRST');
});
}
});
}
function setup() {
return Promise.resolve().then(function() {
//Promise2 executes/is handled differently
return Promise2.map([1], function() {
process.nextTick(function() {
second();
});
throw new Error('test error');
});
});
}
return start();
stdout:
SECOND
FIRST
expected stdout:
FIRST
SECOND
When only a single bluebird package is used as in the script bellow, I get the expected output;
const Promise = require('bluebird');
function second() {
console.log('SECOND');
}
function start() {
return new Promise(function(resolve, reject) {
process.nextTick(tick);
function tick() {
return setup().catch(function(err) {
console.log('FIRST');
});
}
});
}
function setup() {
return Promise.resolve().then(function() {
return Promise.map([1], function() {
process.nextTick(function() {
second();
});
throw new Error('test error');
});
});
}
return start();
This is the case when some dependent npm package requires different version of bluebird or simply project’s dependencies are not flatten out. Understandably this breaks things.
Despite that, Thank you for the amazing library!
Issue Analytics
- State:
- Created 5 years ago
- Comments:6
Top Results From Across the Web
Promise.map concurrency execution order · Issue #708
I am having a problem with the concurrency option for Promise.map. ... This is unintuitive and inconsistent with the behavior of ES6 map...
Read more >Synchronous promise resolution (bluebird vs. jQuery)
In both cases (synchronous with cast or asynchronous resolution), you'll have the correct execution order. Note that having a function being ...
Read more >Bluebird: High-performance SDN for Bare-metal Cloud ...
In the Bluebird model, we collapse two key roles into a single device: 1) logical net- work isolation between customers via Virtual Routing...
Read more >Breeding Season Aggression of Female and Male Eastern ...
Naturally occurring aggression between female eastern bluebirds (Sialia sialis) is dramatic, resulting in severe injuries and even death.
Read more >How to succeed on the pursuit of a PhD
Executing the next actions in efficient batches. The book elaborates on all these steps in more detail, but it could have been written...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
It might be a different version of bluebird and not contain the same methods - for example Bluebird 2 and Bluebird 3.
What’s the implementation reason behind NOT returning the original promise object for object that
isAnyBluebirdPromise
as it is done: https://github.com/petkaantonov/bluebird/blob/49da1ac256c7ee0fb1e07679791399f24648b933/src/thenables.js#L10