Open AaronFriel opened 6 months ago
also interested in this.
this is crazy that there seems to be no way to do basic abort functionality on next server action or vercel ai rsc streams
@AaronFriel Hope you are doing well, did you find any work arround for this. I know that useChat hook has a stop function but in my case I moved away from vercel ai ui in favor of vercel ai rsc, so now that I'm using server actions with streamUI is impossible to send a stop signal.
+1 Please
This is (current) limitation of React. Aborting server actions is not supported.
@lgrammel hopefully this can be solved, I would hope that some folks from Vercel could chime in on the issues on facebook/react, as it's forcing us to abandon server actions in favor of API routes for AI use cases. I'm sure it's also keeping the AI SDK from supporting server actions or recommending them. Cancellation is important!
Does someone found any workaround?
Does someone found any workaround?
await
when calling the server actionawait
Note: The server action continues running, but its result is ignored
Feature Description
Provide an ambient
AbortController
via an API to server actions and a method for cancelling a request.Use Case
Users may wish to cancel and retry long-running AI requests, especially in streaming and langchain-esque scenarios where completion times are on the order of tens of seconds or longer.
Additional context
Attempting to work around the issue by, e.g., passing a Promise to the server action does not work, as Next.js delays calling the server action while the promise resolves. This can be demonstrated by calling a server action with
new Promise<void>((r) => setTimeout(r, 10_000))
and logging the un-awaited value of the promise immediately in the action.Related issues: