-
Notifications
You must be signed in to change notification settings - Fork 27.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Log fetch requests during client-side navigation (#67925)
When the config `logging.fetches` (see https://nextjs.org/docs/app/api-reference/next-config-js/logging) is defined, any fetch requests that are done in server components should be logged. This is currently not the case for client-side navigations in the app router. This PR fixes that, and also cleans up the log format a bit. In addition, cached requests for the purpose of HMR refreshes (see #67527) are explicitly omitted from the logs. **Before** <img width="963" alt="fetch logs before" src="https://github.com/user-attachments/assets/f3d50495-1168-4e75-933e-635931f6efb0"> **After** <img width="908" alt="fetch logs after" src="https://github.com/user-attachments/assets/0933964c-1e02-4f14-b059-1ce536abec71"> Note that warnings for conflicting fetch cache configs are now co-located with the logged fetch metrics. If `logging.fetches` is not enabled, the warnings are still logged, as was the case before. They are now only logged in dev mode though, which was not the case before.
- Loading branch information
1 parent
eeff555
commit 0c3b063
Showing
10 changed files
with
164 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,14 @@ | ||
import { RSC_CONTENT_TYPE_HEADER } from '../../client/components/app-router-headers' | ||
import RenderResult from '../render-result' | ||
import RenderResult, { type RenderResultMetadata } from '../render-result' | ||
|
||
/** | ||
* Flight Response is always set to RSC_CONTENT_TYPE_HEADER to ensure it does not get interpreted as HTML. | ||
*/ | ||
export class FlightRenderResult extends RenderResult { | ||
constructor(response: string | ReadableStream<Uint8Array>) { | ||
super(response, { contentType: RSC_CONTENT_TYPE_HEADER, metadata: {} }) | ||
constructor( | ||
response: string | ReadableStream<Uint8Array>, | ||
metadata: RenderResultMetadata = {} | ||
) { | ||
super(response, { contentType: RSC_CONTENT_TYPE_HEADER, metadata }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.