Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onFinish is never called in useChat args #1248

Open
rob-gordon opened this issue Mar 28, 2024 · 4 comments
Open

onFinish is never called in useChat args #1248

rob-gordon opened this issue Mar 28, 2024 · 4 comments

Comments

@rob-gordon
Copy link

Description

Currently running a bit of code in the onFinish handler of useChat. It's never called. The streaming works just fine but the handler isn't called.

Here you can see the specific line where we would get a console log if it were running:
https://github.com/Frostwork-Media/back-of-the-envelope/blob/19a3e1fdf3d24b36206b01fcc1c1c9088c88b4db/src/app/_components/Chat.tsx#L30-L31

You can test it for yourself at https://backoftheenvelope.app/ or pull the code and try locally.

Code example

const {
    messages,
    input,
    handleInputChange,
    handleSubmit,
    isLoading,
    setMessages,
    reload,
  } = useChat({
    onFinish() {
      console.log("onFinish() ran.");
    },
});

Additional context

Running Next 14, App Router, Served on vercel, running with bun
Repository: https://github.com/Frostwork-Media/back-of-the-envelope
Public URL: https://backoftheenvelope.app/

@chanmathew
Copy link

chanmathew commented Apr 13, 2024

I'm having the same issue on 3.0.22, Sveltekit. onFinish and onResponse is not firing at all.

Downgraded to 3.0.19 and that seems to work.

@hu-qi
Copy link

hu-qi commented Apr 15, 2024

I'm having the same issue on 3.0.22, Sveltekit. onFinish and onResponse is not firing at all.

Downgraded to 3.0.19 and that seems to work.

In my case, the same issue on 3.0.22, and 3.0.19 is work.
Ask for help: are there any incompatible changes?

@lgrammel
Copy link
Collaborator

This is potentially a duplicate of #1316

You can check out #1316 (comment) for upgrade instructions.

@myudak
Copy link

myudak commented Jun 5, 2024

me too the onFinish in nextjs 14 doesnt work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants