New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rejection of a Promise that depends on another promise is extremely slow in V8/Chrome. #501
Comments
Can you reproduce this in node/io |
Yes, this is reproducable in Node.js (v0.10.32) using the following test code: var Promise = require('bluebird')
var x = new Promise(function(resolve) {
setTimeout(function() {
console.log('will now resolve!')
resolve()
}, 1000)
})
function y(task) {
return x.then(function() { throw new Error('it failed') })
}
var tasks = []
for (var i = 0; i < 1000; i ++) tasks.push('Task ' + i)
Promise.all(tasks.map(y))
.then(function() { console.log('done') })
.catch(function() { console.log('caught') }) After If the function |
@dtinth that particular test case did not reproduce the bug for me on iojs / node 0.11.x / node 0.10.x |
It also happens on iojs 1.0.3. I reproduced this on Mac OS X 10.10.1 with Bluebird 2.9.9. This is also reproducible on Ubuntu 13.10 running Node v0.10.28 and Bluebird 2.9.9. |
@dtinth ah, sorry, you're right, I was testing on |
By trying to install various versions, this problem started appearing since 2.8.2.
|
@dtinth I will push a 2.9.10 release as soon as the browser tests come back out, no need to revert to 2.8.1 :) |
@dtinth Fixed in 2.9.10 |
Because petkaantonov/bluebird#501 has been fixed very quickly. Kudos!
Thank you for fixing this very quickly. :) |
Because petkaantonov/bluebird#501 has been fixed very quickly. Kudos!
Because petkaantonov/bluebird#501 has been fixed very quickly. Kudos!
The Story
First, I created a Promise, called
x
.Then I created a function that processes a task, but it depends on
x
, but they all fail:I have 1000 tasks, and I process them all.
The Problem
At the moment
x
is resolved, on Google Chrome with a minified build, the browser freezes for ~10 seconds.The Test Case
https://rawgit.com/dtinth/39520b129f143c66bd40/raw/index.html
The Weirdness
bluebird.js
instead ofbluebird.min.js
, the problem disappears.bluebird
in webpack environment, the problem still appears.The Profile
On my MacBook, it takes 9 seconds to settle the Promise.
Upon zooming, most time is spent on
_rejectCallback
.The Variations
If
y
returns a promise that's eventually fulfilled (instead of rejected), this problem doesn't happen.If each
y
depends on differentx
, this problem doesn't happen. What I mean is thatx
andy
looks like this instead:The text was updated successfully, but these errors were encountered: