stream/iter: fromSync() rejects dual sync/async iterables instead of using Symbol.iterator
stream
### Version
main
### Platform
```text
macOS 26.5.0
```
### Subsystem
stream
### What steps will reproduce the bug?
```js
import { fromSync, textSync } from 'node:stream/iter';
const input = {
*[Symbol.iterator]() {
yield new TextEncoder().encode('sync');
},
async *[Symbol.asyncIterator]() {
yield new TextEncoder().encode('async');
},
};
try {
console.log(textSync(fromSync(input)));
} catch (err) {
console.log(`${err.name}: ${err.message}`);
}
```
### How often does it reproduce? Is there a required condition?
Always
### What is the expected behavior? Why is that the expected behavior?
```console
sync
```
`fromSync()` currently rejects any object with `Symbol.asyncIterator` before checking for `Symbol.iterator`. Per Spec [§8.2](https://stream-iter.jasnell.me/#fromsync-method), only async-only inputs should be rejected here; a dual sync+async iterable should be accepted through its synchronous iterator.
### What do you see instead?
```console
TypeError: The "input" argument must be an a synchronous input (not AsyncIterable). Received an instance of Object
```
### Additional information
_No response_
0 条评论