TypeError: The "iterable" argument must be an instance of Iterable. Received an instance of ReadableStream #1585
Unanswered
jasonChen1982
asked this question in
Q&A
Replies: 2 comments
-
If ReadableStream is a native chrome stream, then you probably have to add a polyfill for making them async readable. ReadableStream.prototype[Symbol.asyncIterator] ??= async function* () {
const reader = this.getReader()
try {
while (true) {
const {done, value} = await reader.read()
if (done) return
yield value
}
}
finally {
reader.releaseLock()
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
-
yeah, thanks @jimmywarting , I get your mean. right, it is if (!globalThis.ReadableStream) {
// `node:stream/web` got introduced in v16.5.0 as experimental
// and it's preferred over the polyfilled version. So we also
// suppress the warning that gets emitted by NodeJS for using it.
try {
const process = require('node:process')
const { emitWarning } = process
try {
process.emitWarning = () => {}
Object.assign(globalThis, require('node:stream/web'))
process.emitWarning = emitWarning
} catch (error) {
process.emitWarning = emitWarning
throw error
}
} catch (error) {
// fallback to polyfill implementation
Object.assign(globalThis, require('web-streams-polyfill/dist/ponyfill.es2018.js'))
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Reproduction
Steps to reproduce the behavior:
TypeError: The "iterable" argument must be an instance of Iterable. Received an instance of ReadableStream
Expected behavior
Screenshots
Your Environment
Additional context
Beta Was this translation helpful? Give feedback.
All reactions