ai
ai copied to clipboard
Handle error/abort for `createStreamableUI`, `createStreamableValue` in `ai/rsc`
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.
any idea how to handle 500 codes from OpenAI with current setup?
Duplicate of #1122