{"id":"078e6eb26c969f6e","repo":"sindresorhus/is","slug":"expected-value-which-is-asynciterable-received","errorCode":null,"errorMessage":"Expected value which is `AsyncIterable`, received value of type `${is(value)}`.","messagePattern":"Expected value which is `AsyncIterable`, received value of type `(.+?)`\\.","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"source/index.ts","lineNumber":1480,"sourceCode":"\t\tthrow new TypeError(message ?? typeErrorMessage('AsyncFunction', value));\n\t}\n}\n\nexport function assertAsyncGenerator(value: unknown, message?: string): asserts value is AsyncGenerator {\n\tif (!isAsyncGenerator(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('AsyncGenerator', value));\n\t}\n}\n\nexport function assertAsyncGeneratorFunction(value: unknown, message?: string): asserts value is AsyncGeneratorFunction {\n\tif (!isAsyncGeneratorFunction(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('AsyncGeneratorFunction', value));\n\t}\n}\n\nexport function assertAsyncIterable<T = unknown>(value: unknown, message?: string): asserts value is AsyncIterable<T> {\n\tif (!isAsyncIterable(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('AsyncIterable', value));\n\t}\n}\n\nexport function assertBigint(value: unknown, message?: string): asserts value is bigint {\n\tif (!isBigint(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('bigint', value));\n\t}\n}\n\nexport function assertBigInt64Array(value: unknown, message?: string): asserts value is BigInt64Array {\n\tif (!isBigInt64Array(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('BigInt64Array', value));\n\t}\n}\n\nexport function assertBigUint64Array(value: unknown, message?: string): asserts value is BigUint64Array {\n\tif (!isBigUint64Array(value)) {\n\t\tthrow new TypeError(message ?? typeErrorMessage('BigUint64Array', value));","sourceCodeStart":1462,"sourceCodeEnd":1498,"githubUrl":"https://github.com/sindresorhus/is/blob/7821031c66cdeb7256a0feb2d506535f9e84fcaf/source/index.ts#L1462-L1498","documentation":"Thrown by `assertAsyncIterable(value)` when the value does not have a callable `[Symbol.asyncIterator]` method. This is the check backing `for await...of` compatibility: sync iterables (arrays, Sets, sync generators) fail it because they implement `Symbol.iterator`, not `Symbol.asyncIterator`.","triggerScenarios":"Passing an array or other sync iterable where an async iterable is required; passing a Promise of an iterable (`Promise<Item[]>`) without awaiting; passing an uncalled `async function*`; environments/polyfills where `Symbol.asyncIterator` is missing so nothing gets tagged.","commonSituations":"Mixing sync and async data sources in a pipeline that requires `for await` inputs; forgetting to `await` a fetch that resolves to a stream; older Node (<10) or ES targets without `Symbol.asyncIterator`; passing a Web ReadableStream in runtimes where it isn't yet async-iterable (older Node/browsers).","solutions":["Await the value first if it's a Promise of an iterable, or call the async generator function to get its iterator.","Wrap sync iterables when the consumer demands async: `(async function * () { yield * syncIterable; })()`.","If sync sources are legitimate, loosen the contract to `assert.iterable` or accept both and branch on `Symbol.asyncIterator in value`.","On older runtimes, upgrade Node/target so `Symbol.asyncIterator` and async-iterable ReadableStream exist."],"exampleFix":"// before\nprocessStream([1, 2, 3]); // sync array, assert.asyncIterable throws\n// after\nprocessStream((async function * () { yield * [1, 2, 3]; })());","handlingStrategy":"type-guard","validationCode":"if (value == null || typeof value[Symbol.asyncIterator] !== 'function') {\n  // wrap or reject before assert.asyncIterable(value)\n}","typeGuard":"function isAsyncIterable(value) {\n  return value != null && typeof value[Symbol.asyncIterator] === 'function';\n}","tryCatchPattern":"try {\n  assert.asyncIterable(value);\n} catch (error) {\n  if (error instanceof TypeError) { /* sync iterable or plain object given */ }\n  else { throw error; }\n}","preventionTips":["Arrays and sync iterables do not implement Symbol.asyncIterator — for-await tolerates them but this assert does not","Node Readable streams are async iterable; ensure your polyfill/runtime actually attaches Symbol.asyncIterator","When accepting both sync and async sources, check is.asyncIterable || is.iterable and normalize"],"tags":["type-assertion","async-iterable","iteration"],"analyzedSha":"7821031c66cdeb7256a0feb2d506535f9e84fcaf","analyzedAt":"2026-07-31T18:34:06.268Z","schemaVersion":2}