Skip to content
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

Promise dispatch methods cause duplicate unhandled rejections #289

Closed
SLaks opened this issue May 9, 2013 · 4 comments
Closed

Promise dispatch methods cause duplicate unhandled rejections #289

SLaks opened this issue May 9, 2013 · 4 comments

Comments

@SLaks
Copy link
Collaborator

SLaks commented May 9, 2013

var Q = require("q");

var promise = Q.reject(new Error("Test Error!"));

promise
    .invoke("someMethod")
    .fail(function (err) { console.log("Swallowed promise failure", err); });

This prints

Swallowed promise failure [Error: Test Error!]
Unhandled rejection reason: Error: Test Error!
    at Object.<anonymous> (.../q-test.js:3:24)
    at node.js:901:3
From previous event:
    at Object.<anonymous> (.../q-test.js:6:3)

Since .fail() handles the rejection, there shouldn't be an unhandled rejection.

Removing .invoke() (or replacing it with the equivalent .then(function (o) { return o.someMethod(); })) fixes it.

@domenic
Copy link
Collaborator

domenic commented May 9, 2013

Yeah, dupe of the unfortunate #238. We want this fixed badly; if you have any ideas let us know!

@domenic domenic closed this as completed May 9, 2013
@SLaks
Copy link
Collaborator Author

SLaks commented May 9, 2013

This happens because fallback() (https://github.com/kriskowal/q/blob/master/q.js#L788) doesn't remove the previous rejection from unhandledRejections.

@domenic
Copy link
Collaborator

domenic commented May 9, 2013

Woah, OK, nice find! I'll try to turn that into a patch tonight or tomorrow. Maybe I'll implement #265 as well in order to be able to test it nicely.

@SLaks
Copy link
Collaborator Author

SLaks commented May 9, 2013

Fixed by #290

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants