Skip to content

Commit

Permalink
Add NEXT_SSG_FETCH_METRICS flag to control fetch metrics during SSG (#…
Browse files Browse the repository at this point in the history
…68378)

This PR allows the users to set `process.env.NEXT_SSG_FETCH_METRICS` to
output fetch metrics during SSG of a build to separate it from
`NEXT_DEBUG_BUILD` which may affect other output.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
  • Loading branch information
mknichel and ijjk authored Aug 1, 2024
1 parent 4d5e8ab commit c470e1c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/next/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2754,7 +2754,7 @@ export default async function build(
// If there was no result, there's nothing more to do.
if (!exportResult) return

if (debugOutput) {
if (debugOutput || process.env.NEXT_SSG_FETCH_METRICS === '1') {
recordFetchMetrics(exportResult)
}

Expand Down
4 changes: 3 additions & 1 deletion packages/next/src/server/lib/patch-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,9 @@ function trackFetchMetric(
if (staticGenerationStore.requestEndedState?.ended) return

const isDebugBuild =
!!process.env.NEXT_DEBUG_BUILD && staticGenerationStore.isStaticGeneration
(!!process.env.NEXT_DEBUG_BUILD ||
process.env.NEXT_SSG_FETCH_METRICS === '1') &&
staticGenerationStore.isStaticGeneration
const isDevelopment = process.env.NODE_ENV === 'development'

if (
Expand Down

0 comments on commit c470e1c

Please sign in to comment.