-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Open
Labels
Dynamic RoutesRelated to dynamic routes.Related to dynamic routes.
Description
Link to the code that reproduces this issue
https://github.com/needle-ai/needle-mcp
To Reproduce
Use Vercel AI SDK's useChat to stream messages. It makes an HTTP request to /api/chat. Request body gets large (around 10kb) since we add many things into the context. However the root cause is not AI SDK since we see the same error for other API routes that dont use AI SDK but have a large payload.
Requests fail with the following error message
SyntaxError: Unexpected token 'a', "are as a S"... is not valid JSON
at JSON.parse (<anonymous>)
at g (/home/bun/app/.next/server/chunks/my-app_260fae17._.js:46:2376)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async /home/bun/app/.next/server/chunks/my-app_260fae17._.js:46:902
at async /home/bun/app/.next/server/chunks/my-app_4aac2b5c._.js:2785:9624
at async r$.do (/home/bun/app/node_modules/next/dist/compiled/next-server/app-route-turbo.runtime.prod.js:23:20293)
at async r$.handle (/home/bun/app/node_modules/next/dist/compiled/next-server/app-route-turbo.runtime.prod.js:23:25083)
at async u (/home/bun/app/.next/server/chunks/my-app_260fae17._.js:46:5991)
at async r$.handleResponse (/home/bun/app/node_modules/next/dist/compiled/next-server/app-route-turbo.runtime.prod.js:19:73806)
at async c (/home/bun/app/.next/server/chunks/my-app_260fae17._.js:46:7029)
I traced the line, and figured out that NextRequest.json() is failing due to malformed json body, I examined and saw that it's partial json.
This issue started happening immediately after we updated from NextJS 14 to 16.
Current vs. Expected behavior
Current behaviour: Payload is truncated.
Expected behaviour: Request body is not truncated.
Provide environment information
1. Build in `standalone` mode (deployed in GCP VM)
2. `bun` version: 1.2.12
3. `node` version: 23
4. `next` version: 16.0.1Which area(s) are affected? (Select all that apply)
Dynamic Routes
Which stage(s) are affected? (Select all that apply)
Other (Deployed)
Additional context
No response
Metadata
Metadata
Assignees
Labels
Dynamic RoutesRelated to dynamic routes.Related to dynamic routes.