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

Runaway promise warning lacks long stack trace when using chained fromCallback() calls #971

Closed
ben-page opened this Issue Jan 22, 2016 · 4 comments

Comments

Projects
None yet
2 participants
@ben-page
Contributor

ben-page commented Jan 22, 2016

I found a case where the runaway promise warning does not include the long stack trace.

var Promise = require('bluebird');
Promise.config({warnings: true, longStackTraces: true});

function fn(cb) {
    setTimeout(cb.bind(null, null, 'result'), 0);
}

Promise.fromCallback(function (callback) {
    fn(callback);
})
.then(function (t) {
    Promise.fromCallback(function (callback) { //runaway promise
        fn(callback);
    });
});
Warning: a promise was created in a handler but was not returned from it
    at Timer.listOnTimeout (timers.js:92:15)
@ben-page

This comment has been minimized.

Show comment
Hide comment
@ben-page

ben-page Jan 22, 2016

Contributor

I'm on 3.1.1

Contributor

ben-page commented Jan 22, 2016

I'm on 3.1.1

@petkaantonov

This comment has been minimized.

Show comment
Hide comment
@petkaantonov

petkaantonov Jan 22, 2016

Owner

Duplicate of #9

Owner

petkaantonov commented Jan 22, 2016

Duplicate of #9

@ben-page

This comment has been minimized.

Show comment
Hide comment
@ben-page

ben-page Jan 22, 2016

Contributor

@petkaantonov I don't think this duplicate of the issue #9. That issue seems to be about an error thrown inside asynchronous (setTimeout) code executed inside a Promise.

My issue is about the runaway Promise warning not including a long stack trace. When the runaway Promise originates from fromCallback(). If it originated from a different method, it would work. I think this may be related to #871. And I do not believe this would require domains, AsyncListener, or similar to solve.

Contributor

ben-page commented Jan 22, 2016

@petkaantonov I don't think this duplicate of the issue #9. That issue seems to be about an error thrown inside asynchronous (setTimeout) code executed inside a Promise.

My issue is about the runaway Promise warning not including a long stack trace. When the runaway Promise originates from fromCallback(). If it originated from a different method, it would work. I think this may be related to #871. And I do not believe this would require domains, AsyncListener, or similar to solve.

@ben-page

This comment has been minimized.

Show comment
Hide comment
@ben-page

ben-page Jan 23, 2016

Contributor

To illustrate my point, here I made a custom implementation of fromCallback() based on the Promise constructor. It creates a long stack trace as expected.

Promise.config({warnings: true, longStackTraces: true});

function fn(cb) {
    setTimeout(cb.bind(null, null, 'result'), 0);
}

function fromCallback(nodeFunction) {
    return new Promise(function(resolve, reject) {
        nodeFunction(function (err, res) {
            if (err)
                return reject(err);

            resolve(res);
        });
    });
}

fromCallback(fn)
    .then(function (t) {
        fromCallback(fn);
    });
Contributor

ben-page commented Jan 23, 2016

To illustrate my point, here I made a custom implementation of fromCallback() based on the Promise constructor. It creates a long stack trace as expected.

Promise.config({warnings: true, longStackTraces: true});

function fn(cb) {
    setTimeout(cb.bind(null, null, 'result'), 0);
}

function fromCallback(nodeFunction) {
    return new Promise(function(resolve, reject) {
        nodeFunction(function (err, res) {
            if (err)
                return reject(err);

            resolve(res);
        });
    });
}

fromCallback(fn)
    .then(function (t) {
        fromCallback(fn);
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment