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

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

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

Comments

@ben-page
Copy link
Contributor

@ben-page 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
Copy link
Contributor Author

@ben-page ben-page commented Jan 22, 2016

I'm on 3.1.1

@petkaantonov
Copy link
Owner

@petkaantonov petkaantonov commented Jan 22, 2016

Duplicate of #9

@ben-page
Copy link
Contributor Author

@ben-page 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
Copy link
Contributor Author

@ben-page 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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.