vercel/ai · error
Unknown chunk type: ${exhaustiveCheck}
Error message
Unknown chunk type: ${exhaustiveCheck} What it means
A fallback `never`-exhaustiveness guard in streamText's internal chunk-type switch. It fires only when the runtime delivers a chunk type the installed SDK version doesn't know, indicating a version mismatch between the ai package and a provider package (or internal state corruption).
Source
Thrown at packages/ai/src/generate-text/stream-text.ts:2488
}
case 'error': {
hasReceivedTerminalChunk = true;
controller.enqueue(chunk);
stepFinishReason = 'error';
break;
}
case 'raw': {
if (include.rawChunks) {
controller.enqueue(chunk);
}
break;
}
default: {
const exhaustiveCheck: never = chunkType;
throw new Error(`Unknown chunk type: ${exhaustiveCheck}`);
}
}
},
// invoke onEnd callback and resolve toolResults promise when the stream is about to close:
async flush(controller) {
// emit an error when an incomplete model stream produced no
// output instead of recording an empty step. incomplete
// streams with partial output retain the partial result:
if (!hasReceivedTerminalChunk && !hasReceivedOutputChunk) {
controller.enqueue({
type: 'error',
error: new NoOutputGeneratedError({
message:
'No output generated. The model stream ended without a finish chunk.',
}),
});
View on GitHub (pinned to 69428b1f8b)
Solutions
- Run `pnpm why @ai-sdk/provider` (or npm ls) and align all @ai-sdk packages and `ai` to versions from the same release.
- Update `ai` to the latest version so new provider part types are handled.
- Check any stream middleware/custom transforms for emitting chunk types outside LanguageModelV* streams.
- Reinstall node_modules to clear duplicated transitive provider packages.
Example fix
// before
"dependencies": { "ai": "^4.0.0", "@ai-sdk/openai": "^2.0.0" } // mismatched majors
// after
"dependencies": { "ai": "^4.3.16", "@ai-sdk/openai": "^1.3.0" } // matching release lines Defensive patterns
Strategy: fallback
Validate before calling
// before starting, verify a single provider version is installed:
// pnpm why @ai-sdk/provider -> expect exactly one version in the tree
import { VERSIONS } from '@ai-sdk/provider-utils'; // log during support debugging
console.log('provider-utils version:', VERSIONS); Try / catch
try {
await streamText({ model, prompt });
} catch (e) {
if (e instanceof Error && e.message.startsWith('Unknown chunk type')) {
console.error('Incompatible ai/@ai-sdk provider versions; upgrade `ai`.');
// fall back to non-streaming generateText or a raw provider client
} else throw e;
} Prevention
- Pin `ai` and all @ai-sdk/* packages to the same release line and upgrade together.
- Run pnpm dedupe / reinstall after version bumps to avoid duplicate provider packages.
- Avoid monkey-patching or middleware that emits nonstandard stream parts.
When it happens
Trigger: Mixing incompatible versions of `ai` and `@ai-sdk/<provider>` (e.g. provider emits a new part type the older ai core doesn't handle); patching/monkey-patching stream parts; custom middleware emitting an unknown chunk type.
Common situations: Partial pnpm dependency resolution leaving two major versions of @ai-sdk/provider in node_modules; upgrading a provider package without upgrading `ai`; third-party middleware producing nonstandard parts.
Related errors
- Unsupported chunk type: ${_exhaustiveCheck}
- Unsupported chunk type: ${_exhaustiveCheck}
- 'element streams in no-schema mode' functionality not suppor
- 'element streams in object mode' functionality not supported
- 'element streams in enum mode' functionality not supported.
AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30).
Data as JSON: /api/errors/cbdab4272dc78e86.
Report an issue: GitHub.