ai icon indicating copy to clipboard operation
ai copied to clipboard

Handle error/abort for `createStreamableUI`, `createStreamableValue` in `ai/rsc`

Open phuctm97 opened this issue 11 months ago • 1 comments

Feature Description

Something like:

import { createStreamableUI, createStreamableValue } from "ai/rsc";

const ui = createStreamableUI();
const value = createStreamableValue();

ui.on("error", () => {});
value.on("close", () => {});

Besides, it would be nice to be able to "natively" communicate error to the React (UI) by calling done with an error:

// This will throw an error in the React tree up to the closest error boundary from the streamable UI (or components consuming the streamable value)
ui.done(new Error("Something went wrong.");

Use Case

The client may have trouble or abort connection with a streamable UI or value. Currently, in these scenarios, there is no way to abort running async tasks in corresponding server actions.

phuctm97 avatar Mar 16 '24 07:03 phuctm97

any idea how to handle 500 codes from OpenAI with current setup?

yahorbarkouski avatar Mar 30 '24 14:03 yahorbarkouski

Duplicate of #1122

lgrammel avatar Aug 14 '24 06:08 lgrammel