next.js
bc51d9bb - [Cache Components] Allow hiding logs after abort (#84579)

Commit
75 days ago
[Cache Components] Allow hiding logs after abort (#84579) When Next.js prerenders with Cache Components enabled it will abort prerenders before they have completed. It is common for user code to log in a catch block and with this new prerendering behavior these logs will trigger frequently for cases where the rejection only happened because we are abandoning the work. This is analagous to treating a fetch rejection as an error even when you pass an abortSignal into the fetch and then abort it. Currently when logs occur after an aborted prerender we dim the log output to signify that the log line is not particuarly important. This is useful and for folks who want to see everything output by their program this is potentially the best behavior. However many log collectors don't support colors and have no way of contextualizing the dimmed log which can lead to them appearing to be more significant than they are. To combat this we expose a new experimental flag that allows you to completely disable logs after aborting. This means the log lines you see are much higher signal. The implementation is somewhat complex because we install the environment extensions as early as possible before any user code can run but we can't install the hiding behavior until we have a config in scope. I've added the hiding installation to next-server and the worker exportPages entrypoints. I believe this is sufficient to cover all contexts in which we will prerender.
Author
Parents
Loading