node-promise icon indicating copy to clipboard operation
node-promise copied to clipboard

Cannot read property 'then' of undefined

Open thesmart opened this issue 12 years ago • 3 comments

There is an uncaughtException being thrown when using allOrNone. I have tried to create a simplified repro of the issue with no success. Maybe this is a bug in the Node core?

I have included a screencast as a demonstration. Not sure what the heck is going on... repros 100% in my app with the debugger and without.

https://dl.dropbox.com/u/288065/node-promise-bug.mov

thesmart avatar Feb 23 '13 22:02 thesmart

Here is the code I produced in an attempt to repro, but it does what is expected and does NOT repro. Maybe this has something to do with running in a context via the Kue module?

var promise = require('node-promise');

var promA = new promise.Promise();

global.setTimeout(function() {
    promA.reject(new Error('A FAIL'));
}, 2000);

var promB = new promise.Promise();

process.nextTick(function() {
    promB.resolve('ok');
});

promise.allOrNone([
    promA,
    promB
]).then(function() {
    console.info('success?');
}, function(err) {
    console.error(err);
});

thesmart avatar Feb 23 '13 22:02 thesmart

"node-promise":"0.5.5",

thesmart avatar Feb 23 '13 22:02 thesmart

I realize now that this was fixed 2 days ago in a branch: https://github.com/MaxMotovilov/node-promise/commit/0f47b8d28a8c1352b0464225dc336812f9a2fd8b

@MaxMotovilov

thesmart avatar Feb 23 '13 22:02 thesmart