Unverified Commit 5abb663b authored by Hendrik Liebau's avatar Hendrik Liebau Committed by GitHub

Don't create client-side debug channel if the feature is disabled (#83699)

Creating the client-side debug channel when
`experimental.reactDebugChannel` is falsy went unnoticed in the
[original PR](https://github.com/vercel/next.js/pull/82748), because
this doesn't provoke any obvious errors. The debug info is still
correctly received through the main RSC stream. But it does create a
memory leak, because it prevents React from closing the Flight response.

On the server side, we were already guarding the feature properly using
the feature flag.
parent 1c341690
......@@ -333,6 +333,8 @@ export function getDefineEnv({
!isTurbopack || (config.experimental.turbopackPersistentCaching ?? false),
'process.env.__NEXT_OPTIMIZE_ROUTER_SCROLL':
config.experimental.optimizeRouterScrolling ?? false,
'process.env.__NEXT_REACT_DEBUG_CHANNEL':
config.experimental.reactDebugChannel ?? false,
}
const userDefines = config.compiler?.define ?? {}
......
......@@ -162,7 +162,11 @@ let debugChannel:
| { readable?: ReadableStream; writable?: WritableStream }
| undefined
if (process.env.NODE_ENV !== 'production' && typeof window !== 'undefined') {
if (
process.env.NODE_ENV !== 'production' &&
process.env.__NEXT_REACT_DEBUG_CHANNEL &&
typeof window !== 'undefined'
) {
const { createDebugChannel } =
require('./dev/debug-channel') as typeof import('./dev/debug-channel')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment