@@ -1121,23 +1121,8 @@ function callWithDebugContextInDEV<A, T>(
11211121 setCurrentOwner(componentDebugInfo);
11221122 try {
11231123 if ( enableOwnerStacks && debugTask ) {
1124- if ( supportsRequestStorage ) {
1125- // Exit the request context while running callbacks.
1126- return debugTask . run (
1127- // $FlowFixMe[method-unbinding]
1128- requestStorage . run . bind (
1129- requestStorage ,
1130- undefined ,
1131- callback . bind ( null , arg ) ,
1132- ) ,
1133- ) ;
1134- }
11351124 return debugTask . run ( callback . bind ( null , arg ) ) ;
11361125 }
1137- if ( supportsRequestStorage ) {
1138- // Exit the request context while running callbacks.
1139- return requestStorage . run ( undefined , callback , arg ) ;
1140- }
11411126 return callback(arg);
11421127 } finally {
11431128 setCurrentOwner ( null ) ;
@@ -2850,11 +2835,23 @@ function logPostpone(
28502835 task : Task | null , // DEV-only
28512836) : void {
28522837 const prevRequest = currentRequest ;
2838+ // We clear the request context so that console.logs inside the callback doesn't
2839+ // get forwarded to the client.
28532840 currentRequest = null ;
28542841 try {
28552842 const onPostpone = request . onPostpone ;
28562843 if ( __DEV__ && task !== null ) {
2857- callWithDebugContextInDEV ( task , onPostpone , reason ) ;
2844+ if ( supportsRequestStorage ) {
2845+ requestStorage . run (
2846+ undefined ,
2847+ callWithDebugContextInDEV ,
2848+ task ,
2849+ onPostpone ,
2850+ reason ,
2851+ ) ;
2852+ } else {
2853+ callWithDebugContextInDEV ( task , onPostpone , reason ) ;
2854+ }
28582855 } else if ( supportsRequestStorage ) {
28592856 // Exit the request context while running callbacks.
28602857 requestStorage . run ( undefined , onPostpone , reason ) ;
@@ -2872,12 +2869,24 @@ function logRecoverableError(
28722869 task : Task | null , // DEV-only
28732870) : string {
28742871 const prevRequest = currentRequest ;
2872+ // We clear the request context so that console.logs inside the callback doesn't
2873+ // get forwarded to the client.
28752874 currentRequest = null ;
28762875 let errorDigest ;
28772876 try {
28782877 const onError = request . onError ;
28792878 if ( __DEV__ && task !== null ) {
2880- errorDigest = callWithDebugContextInDEV ( task , onError , error ) ;
2879+ if ( supportsRequestStorage ) {
2880+ errorDigest = requestStorage . run (
2881+ undefined ,
2882+ callWithDebugContextInDEV ,
2883+ task ,
2884+ onError ,
2885+ error ,
2886+ ) ;
2887+ } else {
2888+ errorDigest = callWithDebugContextInDEV ( task , onError , error ) ;
2889+ }
28812890 } else if ( supportsRequestStorage ) {
28822891 // Exit the request context while running callbacks.
28832892 errorDigest = requestStorage . run ( undefined , onError , error ) ;
0 commit comments