vercel / ai

Build AI-powered applications with React, Svelte, Vue, and Solid
https://sdk.vercel.ai/docs
Other
9.81k stars 1.45k forks source link

onFinish is called twice #980

Open Ali-Hussein-dev opened 8 months ago

Ali-Hussein-dev commented 8 months ago

Description

Version: 2.2.35 Nextjs: 14.1.0 React: 18.2.0 after updating from 2.2.27 I found the onFinish (useCompletion) is called twice which is triggering a bug in my app.

Code example

  const res = useCompletion({
    api: "...",
    onFinish: (prompt, completion) => {
      console.log("onFinish running...") // runs twice
  });
  return { };
};

Additional context

No response

trulymittal commented 2 months ago

@Ali-Hussein-dev Did you find a solution, i am experiencing this on "ai": "^3.2.37",