Unhandled rejected promise error thrown for resolved promise. #252

Closed
curvedmark opened this Issue Apr 3, 2013 · 0 comments

Projects

None yet

1 participant

@curvedmark
var Q = require('q');
var deferred = Q.defer();

deferred.resolve();
deferred.reject();

throws Unhandled rejected promise (no stack): undefined.

If I'm not wrong, according to Promist/A+:

When in fulfilled, a promise:

must not transition to any other state.
must have a value, which must not change.
@domenic domenic added a commit that referenced this issue Apr 6, 2013
@domenic domenic Fix #252: spurious unhandled rejections.
Calling `deferred.resolve()` then `deferred.reject()` would cause a spurious report of an unhandled rejection, because `deferred.reject()` worked by creating a rejected promise, even if `deferred.promise` was already resolved.

Also, clarified some variable names while I was there, like `resolvedPromise` instead of the deceptive `value`. This was especially confusing when the argument `value` to `resolve` and `fulfill` was shadowing the outer one.
0cba230
@domenic domenic added a commit that closed this issue Apr 7, 2013
@domenic domenic Fix #252: spurious unhandled rejections.
Calling `deferred.resolve()` then `deferred.reject()` would cause a spurious report of an unhandled rejection, because `deferred.reject()` worked by creating a rejected promise, even if `deferred.promise` was already resolved.

Also, clarified some variable names while I was there, like `resolvedPromise` instead of the deceptive `value`. This was especially confusing when the argument `value` to `resolve` and `fulfill` was shadowing the outer one.
7c9be41
@domenic domenic closed this in 7c9be41 Apr 7, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment