next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Vercel Logging Broken on app router

Open danielbeardsley opened this issue 1 year ago • 1 comments

Link to the code that reproduces this issue

https://github.com/iFixit/react-commerce/pull/2221

To Reproduce

Migrating a route from the pages router to the app router seems to break the way Vercel parses / interprets console.log() logging output.

Current vs. Expected behavior

Expected Behavior: all log lines for a request are grouped under one request. This is what we see for the pages router: image

Current Behavior: After migrating a route to use the app router, all log lines are treated as individual and separate requests. This breaks all logging integrations and makes logs rather useless. image

Provide environment information

Next: 13.4.12 deployed on vercel

Which area(s) are affected? (Select all that apply)

App Router

Which stage(s) are affected? (Select all that apply)

Vercel (Deployed)

Additional context

I'm not sure if the fault lies with next.js, vercel, or some error in their integration.

danielbeardsley avatar Jan 27 '24 00:01 danielbeardsley

Minimal reproducible example as outlined by Vercel: https://github.com/iFixit/vercel-app-router-logging-example

masonmcelvain avatar Jan 31 '24 22:01 masonmcelvain

Can we get an update on this? This is forcing us to move to a different logging provider.

realshovanshah avatar Mar 28 '24 03:03 realshovanshah

@realshovanshah, We were told by Vercel's support that the splitting of logs into separate lines is expected with the app router.

The main feature that causes the lines to be split is deep in the core of Next. If I remember correctly, each async function is treated as a unique process. This means the logs are no longer tied to a single process and grouped.

We were advised that if we wanted the logs grouped, we should implement our logic / wrap the logs in a logging provider.

jarstelfox avatar Mar 29 '24 16:03 jarstelfox