{"record":{"id":"e2dbc130c4cd7271","repo":"vercel/ai","slug":"unsupported-chunk-type-exhaustivecheck","errorCode":null,"errorMessage":"Unsupported chunk type: ${_exhaustiveCheck}","messagePattern":"Unsupported chunk type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/ai/src/generate-object/output-strategy.ts","lineNumber":297,"sourceCode":"                  for (\n                    ;\n                    publishedElements < array.length;\n                    publishedElements++\n                  ) {\n                    controller.enqueue(array[publishedElements]);\n                  }\n\n                  break;\n                }\n\n                case 'text-delta':\n                case 'finish':\n                case 'error': // suppress error (use onError instead)\n                  break;\n\n                default: {\n                  const _exhaustiveCheck: never = chunk;\n                  throw new Error(\n                    `Unsupported chunk type: ${_exhaustiveCheck}`,\n                  );\n                }\n              }\n            },\n          }),\n        ),\n      );\n    },\n  };\n};\n\nconst enumOutputStrategy = <ENUM extends string>(\n  enumValues: Array<ENUM>,\n): OutputStrategy<string, ENUM, never> => {\n  return {\n    type: 'enum',\n","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/ai/src/generate-object/output-strategy.ts#L279-L315","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before (mixed versions)\n\"dependencies\": { \"ai\": \"^4.0.0\", \"@ai-sdk/openai\": \"^1.0.0\" } // plus stale ai@3 in lockfile\n\n// after\nrm -rf node_modules && pnpm install\n\"dependencies\": { \"ai\": \"^4.3.16\", \"@ai-sdk/openai\": \"^1.3.22\" }","handlingStrategy":"fallback","validationCode":"// before streaming, assert a single SDK version at startup\nimport { VERSION } from 'ai';\nconsole.assert(VERSION === expectedVersion, 'mixed ai versions detected');","typeGuard":"function isKnownChunkType(t: string): boolean {\n  return ['object','text-delta','finish','error','start','start-step','finish-step','reasoning-delta','source','tool-call','tool-input-delta','tool-result','raw'].includes(t);\n}","tryCatchPattern":"try {\n  for await (const el of result.elementStream) { /* ... */ }\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Unsupported chunk type')) {\n    console.error('SDK version skew; reinstall deps', e.message);\n    // fallback: consume full object instead of element stream\n  } else throw e;\n}","preventionTips":["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."],"tags":["streaming","exhaustiveness","version-mismatch","internal-error"],"backgroundTag":"unsupported-chunk-type","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}