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
Using .return() causes promise to be resolved as an empty object in 2.9.31 #689
Comments
@jviotti any help you can offer in isolating this issue to a more reduced test case would be greatly appreciated. |
Also between 2.9.31 and 2.9.30 there isn't any change that could cause anything like this |
Ok the error comes when I use node 0.10 or node 0.12 (I was initially using io.js 2.3). |
Ok this is because in older node.js, the Bluebird uses an optimization where values are ferried in the This demonstrates what is happening: (function() {
function DomainBind(fn) {
return function() {
return fn.call(this);
}
}
var func = function() {
"use strict";
return this;
};
var boundFunc = DomainBind(func);
var result = boundFunc.call(true);
console.log(result instanceof Boolean); // true
console.log(result === true); // false
var strictResult = func.call(true);
console.log(strictResult instanceof Boolean); // false
console.log(strictResult === true); // true
})(); |
Fixed in 2.9.32 |
I'm actually having an issue with the domains change and the traceview module. I'm inclined to put the fault with traceview since it's by nature meddling with bluebird's workings, but perhaps this issue applies after all.
I don't actually know anything about domains, but maybe you can spot what's wrong so I can add it to my ticket with appneta? |
They are calling the internal _addCallbacks method incorrectly from
|
return _addCallbacks.call(this, fulfill, reject, progress, promise, receiver); should be return _addCallbacks.call(this, fulfill, reject, progress, promise, receiver, null); in https://github.com/TimBeyer/cls-bluebird/blob/master/shim.js#L18 |
That would explain it, thanks! |
I'm suddenly having an issue with
.return()
in exactly2.9.31
.If
exports.get()
resolves, then the promise is resolved as an empty object{}
instead oftrue
.Switching to
.then()
fixes the issue:I've created a branch in my project (https://github.com/resin-io/resin-sdk/tree/issue/bluebird-return) locking to
2.9.31
which reproduces the issue (reverting to2.9.30
fixes the issue).By running the test suite you should get something like:
Application Model
.has()
function definition: https://github.com/resin-io/resin-sdk/blob/issue/bluebird-return/lib/models/application.coffee#L104.Application Model
.has()
failing test: https://github.com/resin-io/resin-sdk/blob/issue/bluebird-return/tests/models/application.spec.coffee#L123.Device model
.has()
function definition: https://github.com/resin-io/resin-sdk/blob/issue/bluebird-return/lib/models/device.coffee#L180.Device Model
.has()
failing test: https://github.com/resin-io/resin-sdk/blob/issue/bluebird-return/tests/models/device.spec.coffee#L332.The text was updated successfully, but these errors were encountered: