ZoneAwarePromise.all does not work properly with generators #892
Description
We found this bug from a report of our use of Zone.js in the Application Insights Node.js SDK causing generator functions to not get called: microsoft/ApplicationInsights-node.js#267
Native promises in Node.js support taking the result of a generator function as an argument to Promise.all
, and wait for all yielded promises to complete. For example:
var generator = function*() {
yield Promise.resolve('1');
yield Promise.resolve('2');
yield Promise.resolve('3');
return;
};
Promise.all(generator()).then(val=>{
console.log(val);
})
will print out [ '1', '2', '3' ]
. This breaks when including zone into the project.
The code for the ZoneAwarePromise.all
method correctly uses a for-of loop to iterate its value (see
Line 273 in a66595a
However, the compiled source, for zone-node at least, converts this into a standard for loop iterating an index against value.length
(see
Line 893 in b9c0d9c
The end result is executing the code sample above with zone.js included is getting the following printed out: []