kriszyp / node-promise

Promise utilities for Node
397 stars 42 forks source link

Cannot read property 'then' of undefined #9

Open thesmart opened 11 years ago

thesmart commented 11 years ago

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 commented 11 years ago

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 commented 11 years ago

"node-promise":"0.5.5",

thesmart commented 11 years ago

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

@MaxMotovilov