Bug Report
π Search Terms
Async return AsyncIterator
π Version & Regression Information
- This changed between versions 4.8.4 and 4.9.5
β― Playground Link
Playground link with relevant code
π» Code
const LIMIT = 3;
const asyncIterable = {
[Symbol.asyncIterator]() {
let i = 0;
return {
next() {
const done = i === LIMIT;
const value = done ? undefined : i++;
return Promise.resolve({ value, done });
},
return() {
console.log("RETURN");
// This will be reached if the consumer called 'break' or 'return' early in the loop.
return { done: true, value: undefined };
},
};
},
};
(async () => {
for await (const num of asyncIterable) {
console.log(num);
break;
}
})();
π Actual behavior
Outputted "0", the return function of the async iterator was never called.
π Expected behavior
Output "0" and "RETURN" to the log. This would show that the return() function was called.
Bug Report
π Search Terms
Async return AsyncIterator
π Version & Regression Information
β― Playground Link
Playground link with relevant code
π» Code
π Actual behavior
Outputted "0", the return function of the async iterator was never called.
π Expected behavior
Output "0" and "RETURN" to the log. This would show that the return() function was called.