-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Improve Warning: a promise was created in a handler but none were returned from it #1205
Comments
I think we can fix #1 (PR #1207 created) - about the other two:
|
By 2) I didn't mean that the stack trace should be omitted, rather that the line should be repeated. For example: function a() { new Promise(()=>{}); }
function b() { return a(); }
function d() {
return x().then(function c(res) {
res += …;
b();
})
}
d() Now I'd love to get
|
The merged PR only added the link, new PR welcome that adds the line too |
Addressed both additional requirements @bergus. "use strict";
var Promise = require("./js/debug/bluebird");
Promise.config({warnings: true})
function x() {
return Promise.delay(3);
}
function a() { Promise.delay() }
function b() { return a(); }
function d() {
return x().then(function c(res) {
res += 3;
b();
}).then(function(){})
}
d() Now gives:
"use strict";
var Promise = require("./js/debug/bluebird");
Promise.config({warnings: true})
function x() {
return Promise.delay(3);
}
function a() { new Promise(function() {}) }
function b() { return a(); }
function d() {
return x().then(function c(res) {
res += 3;
b();
}).then(function(){})
}
d() Now gives:
|
Released in 3.4.3 Also, in node v6 without --trace-warnings the warning is now quite useful even without stack:
|
Gorgeous, thank you! |
It seems this warning is happening a lot and confusing quite a few users (see #508, #854, #1054, #1084 and many others).
Here are some ideas how the message could be improved:
return
is missing, the rest of the stack trace is not so important. I bet 80 to 90 percent of cases are "Right I forgot thereturn
here", and only the minority is "but that function doesn't seem to return a promise, why would I need to return?" or "but I do return the result of the function, why is it not a promise?" that would make it necessary to look at the stack trace.new Promise
/then
/whatever" and "then
/catch
/whatever calls the handler"The text was updated successfully, but these errors were encountered: