Skip to content

Tracing has missing output when called inside nextjs after() or waitUntil function #7912

@micmania1

Description

@micmania1

Description

I've noticed that LLM calls within after() and waitUntil don't get properly traced. They end up with no output and almost 0 latency (eg. 0.1s).

I initially raised an issue against langsmith which can be found here: langchain-ai/langsmith-sdk#1874

However, I've since tried the same thing with vercel-langfuse and I'm seeing the same problem leading me to think this is an upstream issue, either in this repo or in nextjs. I tried to debug myself to try and pinpoint the issue but I didn't have much luck.

Reproduce

Here are two langsmith examples which have the problem: https://gist.github.com/micmania1/468c16c76459a5f6bba159c27977258b#file-new-exporter-route-ts

AI SDK Version

"@ai-sdk/google": "^2.0.0",
"ai": "^5.0.0",

Note: This problem exists both in ai SDK v4 and v5.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions