Skip to content

Internal-API stream: error frames crash the client instead of showing the message #2176

Description

@felladrin

Surfaced by a role-based review; verified against current code.

Problem: When the /inference proxy exhausts all models, the server emits data: {"error": "..."} (server/internalApiEndpointServerHook.ts sendSseError). The client (client/modules/textGenerationWithInternalApi.ts:96) blindly reads parsedLine.choices[0].delta.content on every frame — an error frame has no .choices, so it throws TypeError and the real error the server sent never reaches the user or the logs.

Fix: In processStreamResponse, detect parsedLine.error and throw a ChatGenerationError with that message; guard choices?.[0]?.delta?.content. Add a test feeding an error frame.

Files: client/modules/textGenerationWithInternalApi.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions