Version
main
Platform
Subsystem
stream
What steps will reproduce the bug?
import { from, text } from 'node:stream/iter';
async function* asyncGenerator() {
yield 'data';
}
try {
console.log(await text(from([asyncGenerator()])));
} catch (error) {
console.log(`${error.name}: ${error.code ?? error.message}`);
}
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
from([asyncGenerator()]) should throw, because the outer source is a sync iterable and the nested value is async-only.
Spec §8.1 says that when from() treats a sync iterator as an async source, nested async iterables and toAsyncStreamable are unsupported. The sync-iterator fallback currently routes nested values through normalizeAsyncValue(), which accepts async iterables and toAsyncStreamable, so the nested async generator is consumed instead of rejected.
What do you see instead?
Additional information
No response
Version
main
Platform
Subsystem
stream
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
from([asyncGenerator()])should throw, because the outer source is a sync iterable and the nested value is async-only.Spec §8.1 says that when
from()treats a sync iterator as an async source, nested async iterables andtoAsyncStreamableare unsupported. The sync-iterator fallback currently routes nested values throughnormalizeAsyncValue(), which accepts async iterables andtoAsyncStreamable, so the nested async generator is consumed instead of rejected.What do you see instead?
dataAdditional information
No response