-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix double resolving of misbehaving promises that returned rejections. #76
Conversation
Any chance of getting a test with this? Not sure if it should go in |
As I understand it (from reading the code, not from seeing any spec) when you call |
@ForbesLindesay This looks like a good fix to me. Let’s make tests to verify the progression. @domenic I would like to move in the direction of using Jasmine and eventually removing the previous CommonJS testing scaffold. However, we can’t do that until continuous integration with Travis on Node makes use of the Jasmine specs. Maybe we can even use PhantomJS with Travis to do continuous integration for WebKit. |
if (done) { | ||
return; | ||
} | ||
done = true; | ||
deferred.resolve(_fulfilled(value)); | ||
}, function (exception) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this rejection function and the other rejection function are now identical, does it make sense to refactor it such that it's just passing (say) a direct reference to a suitably-modified _rejected
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You have prompted me to wonder why I’m sending nested when messages at all. All the tests pass with a single layer.
Rather than factor out the common rejection, I think I will factor out the nested "when".
Good eye.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I am similarly confused. I've been poking and prodding at the code today to try to really get what's going on. Still not there…
Hey there. I've been trying to work my way through this code a bit more, and I've begun to wonder if the For example, take this code: var rej = Q.reject(new Error("umm"));
Q.when(rej, function () {}, function () {}); The call to
Back in In the original bug I filed (issue #75), a similar pattern of double calls ends up happening, except on the functions passed into the inner What I'm wondering is if Thanks again. I'm learning a lot from all this. |
@kriskowal Want to take another look at this area? |
Still hadn't been resolved as far as I know? It doesn't directly affect me, but we should probably look to get this fixed. |
@danfuzz After taking some time to dig in to this, I think you are right that |
See #76 for some discussion. The fix credit goes to @ForbesLindesay.
OK so I basically merged this fix. But I still think there is some crazy stuff going on inside the I tried to remove a nesting level as per Kris's earlier comment but that broke all the tests. I wonder if fc2ba18 was the reason they were succeeding for Kris. Anyway, @kriskowal, @ForbesLindesay, and @danfuzz, would love to hear your thoughts on the deeper issues and possible fixes. For now though a bugfix seemed prudent. |
@domenic I'm afraid the last research I did on the topic was a couple of months ago, with the results posted here. |
beyond working out that this change would fix it, I'm not really that sure what's going on, I think some work may need to go into refactoring at some point :s |
This is intended to fix issue #75. It'll need someone to code review and make sure I've done this right, but it seems to work and make sense, providing I've correctly understood the intended behaviour.