{"record":{"id":"cbdab4272dc78e86","repo":"vercel/ai","slug":"unknown-chunk-type-exhaustivecheck","errorCode":null,"errorMessage":"Unknown chunk type: ${exhaustiveCheck}","messagePattern":"Unknown chunk type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/ai/src/generate-text/stream-text.ts","lineNumber":2488,"sourceCode":"                    }\n\n                    case 'error': {\n                      hasReceivedTerminalChunk = true;\n                      controller.enqueue(chunk);\n                      stepFinishReason = 'error';\n                      break;\n                    }\n\n                    case 'raw': {\n                      if (include.rawChunks) {\n                        controller.enqueue(chunk);\n                      }\n                      break;\n                    }\n\n                    default: {\n                      const exhaustiveCheck: never = chunkType;\n                      throw new Error(`Unknown chunk type: ${exhaustiveCheck}`);\n                    }\n                  }\n                },\n\n                // invoke onEnd callback and resolve toolResults promise when the stream is about to close:\n                async flush(controller) {\n                  // emit an error when an incomplete model stream produced no\n                  // output instead of recording an empty step. incomplete\n                  // streams with partial output retain the partial result:\n                  if (!hasReceivedTerminalChunk && !hasReceivedOutputChunk) {\n                    controller.enqueue({\n                      type: 'error',\n                      error: new NoOutputGeneratedError({\n                        message:\n                          'No output generated. The model stream ended without a finish chunk.',\n                      }),\n                    });\n","sourceCodeStart":2470,"sourceCodeEnd":2506,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/ai/src/generate-text/stream-text.ts#L2470-L2506","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\n\"dependencies\": { \"ai\": \"^4.0.0\", \"@ai-sdk/openai\": \"^2.0.0\" } // mismatched majors\n// after\n\"dependencies\": { \"ai\": \"^4.3.16\", \"@ai-sdk/openai\": \"^1.3.0\" } // matching release lines","handlingStrategy":"fallback","validationCode":"// before starting, verify a single provider version is installed:\n// pnpm why @ai-sdk/provider  -> expect exactly one version in the tree\nimport { VERSIONS } from '@ai-sdk/provider-utils'; // log during support debugging\nconsole.log('provider-utils version:', VERSIONS);","typeGuard":null,"tryCatchPattern":"try {\n  await streamText({ model, prompt });\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Unknown chunk type')) {\n    console.error('Incompatible ai/@ai-sdk provider versions; upgrade `ai`.');\n    // fall back to non-streaming generateText or a raw provider client\n  } else throw e;\n}","preventionTips":["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."],"tags":["streaming","version-mismatch","internal"],"backgroundTag":"sdk-version-mismatch","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}