[▲ Vercel Community](/) · [Categories](/categories) · [Latest](/latest) · [Top](/top) · [Live](/live) [Feedback](/c/feedback/8) # onStepFinish not being called after stop() 221 views · 1 like · 3 posts Fazufi (@fazufi) · 2024-12-24 The streamText onStepFinish and onFinish events are not triggered when useChat stop() is called. Pauline P. Narvas (@pawlean) · 2024-12-24 · ♥ 1 Thanks for sharing this, @fazufi and welcome to the Vercel Community! Could you share any reproducible example for us? I'll pass it onto the team :smile: Fazufi (@fazufi) · 2024-12-25 When I click the **Stop Streaming** button, the `onStepFinish` and `onFinish` callbacks are not triggered. This issue has already been reported in November at the following link: https://github.com/vercel/ai/issues/3527 but no response has been provided yet. may codes: (NEXT.JS) FE: ``` import { useChat } from 'ai/react' const { messages, stop, append, ...restChat } = useChat({ api: `/api/chat`, }); <button onClick={() => stop()}> stop streaming </button> ``` BE (app/api/chat/route.ts): ``` import { streamText } from "ai"; const res = await streamText({ model: openaiSdk("gpt-4o-2024-08-06"), maxTokens: 2000, temperature: 0, messages, onStepFinish: async () => { console.log("stepFinish triggered"); }, onFinish: async () => { console.log("finish triggered"); }, }); return res.toDataStreamResponse(); ```