Skip to content

Promise.reject(reason) often fires and ignores exceptions -- not debug friendly #144

Description

@jparker-hbo

The docs say "Promise.reject(dynamic reason) -> Promise" but the code does this:

function markAsOriginatingFromRejection(e) {
    try {
        notEnumerableProp(e, "isAsync", true);
    }
    catch(ignore) {}
}
function notEnumerableProp(obj, name, value) {
    var descriptor = {
        value: value,
        configurable: true,
        enumerable: false,
        writable: true
    };
    es5.defineProperty(obj, name, descriptor);
    return obj;
}

So if "reason" is undefined or something that can't have a property defined like a string literal, then it throws and ignores it.

This doesn't crash, but if you're using "pause on all exceptions" in Chrome, it's annoying. Also, then the "isAsync" property won't exist... does that cause problems later?

If you like the existing behavior, then the docs should change to say that "reason" needs to be an object.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions