Fix NEXT_PRIVATE_DEBUG_CACHE to check truthy/falsy values instead of just existence #83727
+130
−10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Updates all instances across the codebase where debug logging is enabled by checking only the existence of the
NEXT_PRIVATE_DEBUG_CACHE
environment variable to instead check the truthy or falsy value of the variable.Problem
Previously, debug logging was enabled whenever
NEXT_PRIVATE_DEBUG_CACHE
was set to any value, including falsy values like'0'
,'false'
, or'no'
. This made it difficult to explicitly disable debug logging once enabled.Solution
Created a centralized helper function
isDebugCacheEnabled()
that properly checks for specific truthy values:'1'
,'true'
,'yes'
(case-insensitive)'0'
,'false'
,'no'
, empty string, or unsetChanges Made
packages/next/src/server/lib/debug-utils.ts
with theisDebugCacheEnabled()
helper functionpackages/next/src/server/use-cache/handlers.ts
packages/next/src/server/use-cache/use-cache-wrapper.ts
packages/next/src/server/app-render/app-render.tsx
packages/next/src/server/route-modules/app-route/module.ts
packages/next/src/server/lib/incremental-cache/file-system-cache.ts
packages/next/src/server/lib/incremental-cache/index.ts
packages/next/src/server/lib/cache-handlers/default.external.ts
examples/cache-handler-redis/cache-handler.js
to use proper logic inlineBackward Compatibility
This change maintains backward compatibility for common use cases:
NEXT_PRIVATE_DEBUG_CACHE=1
orNEXT_PRIVATE_DEBUG_CACHE=true
continues to workTesting
The helper function correctly handles all edge cases including:
'TRUE'
,'Yes'
work)' true '
works)'0'
,'false'
,'no'
,''
,undefined
)This pull request was created as a result of the following prompt from Copilot chat.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.