vercel/ai · error
Unsupported chunk type: ${_exhaustiveCheck}
Error message
Unsupported chunk type: ${_exhaustiveCheck} What it means
The array-mode element stream transform exhaustively switches over every ObjectStreamPart type and throws this Error in the `default` branch. TypeScript's `_exhaustiveCheck: never` guarantees this is unreachable when the switch covers all chunk types, so at runtime it signals that the library received a stream part type it does not recognize — usually a version mismatch between the `ai` package internals or corrupted/intercepted stream data.
Source
Thrown at packages/ai/src/generate-object/output-strategy.ts:297
for (
;
publishedElements < array.length;
publishedElements++
) {
controller.enqueue(array[publishedElements]);
}
break;
}
case 'text-delta':
case 'finish':
case 'error': // suppress error (use onError instead)
break;
default: {
const _exhaustiveCheck: never = chunk;
throw new Error(
`Unsupported chunk type: ${_exhaustiveCheck}`,
);
}
}
},
}),
),
);
},
};
};
const enumOutputStrategy = <ENUM extends string>(
enumValues: Array<ENUM>,
): OutputStrategy<string, ENUM, never> => {
return {
type: 'enum',
View on GitHub (pinned to 69428b1f8b)
Solutions
- Run `pnpm install` freshly and verify only one version of `ai` (and `@ai-sdk/*`) is in the lockfile (`pnpm why ai`).
- Rebuild after upgrading so the transform and the stream-part types come from the same package version.
- Remove or fix custom middleware/provider patches that inject unknown chunk types into the object stream.
- If reproducible on one consistent version, file a bug with the chunk type shown in the message.
Example fix
// before (mixed versions)
"dependencies": { "ai": "^4.0.0", "@ai-sdk/openai": "^1.0.0" } // plus stale ai@3 in lockfile
// after
rm -rf node_modules && pnpm install
"dependencies": { "ai": "^4.3.16", "@ai-sdk/openai": "^1.3.22" } Defensive patterns
Strategy: fallback
Validate before calling
// before streaming, assert a single SDK version at startup
import { VERSION } from 'ai';
console.assert(VERSION === expectedVersion, 'mixed ai versions detected'); Type guard
function isKnownChunkType(t: string): boolean {
return ['object','text-delta','finish','error','start','start-step','finish-step','reasoning-delta','source','tool-call','tool-input-delta','tool-result','raw'].includes(t);
} Try / catch
try {
for await (const el of result.elementStream) { /* ... */ }
} catch (e) {
if (e instanceof Error && e.message.startsWith('Unsupported chunk type')) {
console.error('SDK version skew; reinstall deps', e.message);
// fallback: consume full object instead of element stream
} else throw e;
} Prevention
- Keep `ai` and all `@ai-sdk/*` packages on one consistent version.
- Deduplicate dependencies (`pnpm why ai`) after upgrades.
- Full rebuild/restart after SDK upgrades.
- Don't inject custom chunk types into SDK streams.
When it happens
Trigger: A new ObjectStreamPart variant is emitted by a newer/patched `ai` runtime while this transform is from a different version (mixed package versions, duplicated `ai` installs, bundler deduplication issues). Also possible when stream chunks are injected/modified by custom middleware or patched providers.
Common situations: Monorepos with two versions of `ai` resolved simultaneously; stale node_modules after an upgrade; custom provider wrappers that emit non-standard stream parts into the object stream.
Related errors
- Unsupported chunk type: ${_exhaustiveCheck}
- Unknown 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/e2dbc130c4cd7271.
Report an issue: GitHub.