sbkl
sbkl3w ago

http actions with abort signal

I am using the ai package from vercel and stream some llm output. I want to handle client disconnection with the abortSignal property when the user reloads the browser manually but it seems that convex http actions don't support it at the moment? I am using http actions with hono. Getting this error: "Not implemented: get signal for Request. Consider calling an action defined in Node.js instead (https://docs.convex.dev/functions/actions)."
import { streamText } from "ai";

app.post(
"/api/stream",
async (ctx) => {

const signal = ctx.req.raw.signal;

signal.addEventListener("abort", async (data) => {
console.log("Stream aborted by client", sectionId, data);
});

const result = streamText({
model: model,
system,
prompt,
abortSignal: signal,
onFinish: async ({ usage, text, ...rest }) => {
// Handle end of streaming
},
});

return result.toDataStreamResponse();
},
);
import { streamText } from "ai";

app.post(
"/api/stream",
async (ctx) => {

const signal = ctx.req.raw.signal;

signal.addEventListener("abort", async (data) => {
console.log("Stream aborted by client", sectionId, data);
});

const result = streamText({
model: model,
system,
prompt,
abortSignal: signal,
onFinish: async ({ usage, text, ...rest }) => {
// Handle end of streaming
},
});

return result.toDataStreamResponse();
},
);
Actions | Convex Developer Hub
Actions can call third party services to do things such as processing a payment
1 Reply
Convex Bot
Convex Bot3w ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!

Did you find this page helpful?