Skip to content

I want to report a bug... #433

@gujiao123

Description

@gujiao123

Bug Description

When using <Streamdown> with the streamdown-code plugin for text streaming, if the model output's code block language identifier gets network-truncated (for instance, the model intends to output rust, but the current chunk only receives the string rus), the internal normalizeLanguage function inside streamdown-code returns this unrecognized/truncated language name "rus" unmodified to the Shiki engine.

Because Shiki cannot find a language package named "rus", it throws an exception:
ShikiError: Language rus is not included in this bundle.

Although this exception is caught by a .catch block in streamdown-code/index.ts which logs a console.error, it does not provide any graceful fallback rendering result (TokensResult), nor does it recover the Promise chain. This leads to an irreversible blockage in the React rendering cycle, causing a Fatal Error in the downstream React component tree (the streaming message bubble) and terminating the rendering of all subsequent streamed text.

To Reproduce

  1. Import and render <Streamdown> in a React project, configuring plugins={{ code: codePlugin }}.
  2. Critical Condition: Simulate a slow stream by setting chunk size to 1.
  3. Start streaming a Markdown text. When the stream hangs at the truncated identifier ```rus, before the final t of rust is received.
  4. Observe Console: Immediately throws [Streamdown Code] Failed to highlight code: ShikiError: Language rus is not included in this bundle.
  5. Observe UI: The React rendering pipeline breaks, resulting in a white screen for that area or a permanent halt in the rendering of that message.

Expected Behavior

The renderer should gracefully fallback to plain text highlighting when it encounters an unknown or truncated language identifier like rus. This ensures the UI remains stable while waiting for the subsequent chunk to complete the identifier (e.g., to rust).

Actual Behavior

When receiving the truncated ```rus, the plugin fails to provide any fallback. It throws an unhandled error, causing the entire message bubble component to crash (blank screen) and preventing any further rendering.

Code Sample

Streamdown Version

Streamdown Version: 2.3.0 (@streamdown/code: 1.0.3)

React Version

18

Node.js Version

No response

Browser(s)

No response

Operating System

None

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions