* Returns an AsyncIterator that yields Uint8Array[] batches of * incoming data. Only one iterator can be obtained per stream. * Non-readable streams return an immediately-finished iterator. * @yields {Uint8Array[]}
()
| 1636 | * @yields {Uint8Array[]} |
| 1637 | */ |
| 1638 | async *[SymbolAsyncIterator]() { |
| 1639 | assertIsQuicStream(this); |
| 1640 | const inner = this.#inner; |
| 1641 | if (inner.iteratorLocked) { |
| 1642 | throw new ERR_INVALID_STATE('Stream is already being read'); |
| 1643 | } |
| 1644 | inner.iteratorLocked = true; |
| 1645 | |
| 1646 | inner.reader ??= this.#handle?.getReader(); |
| 1647 | // Non-readable stream (outbound-only unidirectional, or closed) |
| 1648 | if (!inner.reader) return; |
| 1649 | |
| 1650 | yield* createBlobReaderIterable(inner.reader, { |
| 1651 | getReadError: () => { |
| 1652 | // The read side ends for one of three reasons: |
| 1653 | // * Clean FIN received from the peer (state.finReceived |
| 1654 | // === true). The iterator stops without calling this; |
| 1655 | // fall through to the generic state error if it does. |
| 1656 | // * Peer sent us a RESET_STREAM. The C++ side records the |
| 1657 | // code in state.resetCode regardless of whether the JS |
| 1658 | // onreset handler was attached. state.finReceived stays |
| 1659 | // false because no FIN was seen. |
| 1660 | // * We aborted locally via stream.resetStream() or |
| 1661 | // stream.stopSending(). Both paths run EndReadable in |
| 1662 | // C++, setting state.readEnded without setting |
| 1663 | // state.finReceived. There is no peer code to surface. |
| 1664 | if (inner.state.readEnded && !inner.state.finReceived) { |
| 1665 | const peerResetCode = inner.state.resetCode; |
| 1666 | if (peerResetCode !== undefined && peerResetCode > 0n) { |
| 1667 | return new ERR_QUIC_STREAM_RESET(Number(peerResetCode)); |
| 1668 | } |
| 1669 | return new ERR_QUIC_STREAM_ABORTED( |
| 1670 | 'Stream aborted before FIN was received'); |
| 1671 | } |
| 1672 | return new ERR_INVALID_STATE('The stream is not readable'); |
| 1673 | }, |
| 1674 | }); |
| 1675 | } |
| 1676 | |
| 1677 | /** |
| 1678 | * True if the stream is still pending (i.e. it has not yet been opened |
nothing calls this directly
no test coverage detected