You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We just spent a day yesterday to debug a very weird "bug" in NPM Promise library. We forgot to put array brackets for Promise.all() function but the code still worked... The worst part that it was very hard to debug since our async functions looked fine and worked fine, but the final Promise.all() was doing bizarre things.
var Promise = require('promise');
function async(options) {
options = options || {};
return new Promise(function(resolve, reject) {
setTimeout(function() {
console.log('async func complete. going to resolve', options.value);
resolve(options.value);
}, options.time);
});
}
// no array was passed into the Promise.all()
Promise.all(
async({
value: 'Hello',
time: 2000
}),
async({
value: 'Alex',
time: 1000
})
)
.then(function(result) { console.log('All done. Our result is:'); console.log(result); })
.catch(function(error) { console.log(error); });
Browser version of promise works properly and throws and error TypeError: Argument of Promise.all is not iterable . NPM module works and its result is very confusing.
The text was updated successfully, but these errors were encountered:
We just spent a day yesterday to debug a very weird "bug" in NPM Promise library. We forgot to put array brackets for
Promise.all()
function but the code still worked... The worst part that it was very hard to debug since our async functions looked fine and worked fine, but the finalPromise.all()
was doing bizarre things.Take a look at this fiddle
Now go to online npm prototyping environment and paste the following code (which is almost identical to the one in the fiddle)
Browser version of promise works properly and throws and error
TypeError: Argument of Promise.all is not iterable
. NPM module works and its result is very confusing.The text was updated successfully, but these errors were encountered: