{"record":{"id":"92fd374d975c8435","repo":"vercel/ai","slug":"append-the-current-value-is-not-a-string-rece","errorCode":null,"errorMessage":".append(): The current value is not a string. Received: ${typeof currentValue}","messagePattern":"\\.append\\(\\): The current value is not a string\\. Received: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/rsc/src/streamable-value/create-streamable-value.ts","lineNumber":229,"sourceCode":"      const resolvePrevious = resolvable.resolve;\n      resolvable = createResolvablePromise();\n\n      updateValueStates(value);\n      currentPromise = resolvable.promise;\n      resolvePrevious(createWrapped());\n\n      warnUnclosedStream();\n\n      return streamable;\n    },\n    append(value: T) {\n      assertStream('.append()');\n\n      if (\n        typeof currentValue !== 'string' &&\n        typeof currentValue !== 'undefined'\n      ) {\n        throw new Error(\n          `.append(): The current value is not a string. Received: ${typeof currentValue}`,\n        );\n      }\n      if (typeof value !== 'string') {\n        throw new Error(\n          `.append(): The value is not a string. Received: ${typeof value}`,\n        );\n      }\n\n      const resolvePrevious = resolvable.resolve;\n      resolvable = createResolvablePromise();\n\n      if (typeof currentValue === 'string') {\n        currentPatchValue = [0, value];\n        (currentValue as string) = currentValue + value;\n      } else {\n        currentPatchValue = undefined;\n        currentValue = value;","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/rsc/src/streamable-value/create-streamable-value.ts#L211-L247","documentation":"append() only works on streamable values whose current value is a string (or undefined for a fresh value). If the value has been set to any other type via update() or the initial value, this error is thrown, reporting the actual typeof the current value.","triggerScenarios":"Creating createStreamableValue({someObject}) or calling .update({...}) / .update(42), then calling .append('text') — the current value is no longer a string.","commonSituations":"Mixing text-streaming append() with whole-value update() on the same streamable; initializing a streamable with a non-string value intending to append to it later.","solutions":["Use append() exclusively from the start on a createStreamableValue() with no initial (or a string initial) value","Use update() instead of append() if you intend to replace the value with non-string data","Use separate streamable values: one for streamed text (append), one for structured data (update)","Reset the value to a string with update('') before appending"],"exampleFix":"// before\nconst v = createStreamableValue({ count: 0 });\nv.append('hi'); // throws\n// after\nconst v = createStreamableValue('');\nv.append('hi');","handlingStrategy":"validation","validationCode":"function safeAppend(streamable, current, chunk) {\n  if (typeof current !== 'string' && typeof current !== 'undefined') {\n    throw new TypeError('append requires a string-valued streamable, got: ' + typeof current);\n  }\n  streamable.append(chunk);\n}","typeGuard":"function canAppendTo(value) {\n  return typeof value === 'string' || typeof value === 'undefined';\n}","tryCatchPattern":"try {\n  streamable.append(chunk);\n} catch (e) {\n  if (!/current value is not a string/.test(String(e.message))) throw e;\n  streamable.update(String(chunk)); // fall back to replace-mode\n}","preventionTips":["Never mix update() with non-string values and append() on the same streamable","Create append-style streams with createStreamableValue() and no initial object","Keep a convention: one streamable per value type (text vs structured)"],"tags":["streaming","rsc","type-error","append"],"backgroundTag":"invalid-stream-value-type","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}