@@ -1121,23 +1121,8 @@ function callWithDebugContextInDEV<A, T>(
1121
1121
setCurrentOwner(componentDebugInfo);
1122
1122
try {
1123
1123
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
- }
1135
1124
return debugTask . run ( callback . bind ( null , arg ) ) ;
1136
1125
}
1137
- if ( supportsRequestStorage ) {
1138
- // Exit the request context while running callbacks.
1139
- return requestStorage . run ( undefined , callback , arg ) ;
1140
- }
1141
1126
return callback(arg);
1142
1127
} finally {
1143
1128
setCurrentOwner ( null ) ;
@@ -2850,11 +2835,23 @@ function logPostpone(
2850
2835
task : Task | null , // DEV-only
2851
2836
) : void {
2852
2837
const prevRequest = currentRequest ;
2838
+ // We clear the request context so that console.logs inside the callback doesn't
2839
+ // get forwarded to the client.
2853
2840
currentRequest = null ;
2854
2841
try {
2855
2842
const onPostpone = request . onPostpone ;
2856
2843
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
+ }
2858
2855
} else if ( supportsRequestStorage ) {
2859
2856
// Exit the request context while running callbacks.
2860
2857
requestStorage . run ( undefined , onPostpone , reason ) ;
@@ -2872,12 +2869,24 @@ function logRecoverableError(
2872
2869
task : Task | null , // DEV-only
2873
2870
) : string {
2874
2871
const prevRequest = currentRequest ;
2872
+ // We clear the request context so that console.logs inside the callback doesn't
2873
+ // get forwarded to the client.
2875
2874
currentRequest = null ;
2876
2875
let errorDigest ;
2877
2876
try {
2878
2877
const onError = request . onError ;
2879
2878
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
+ }
2881
2890
} else if ( supportsRequestStorage ) {
2882
2891
// Exit the request context while running callbacks.
2883
2892
errorDigest = requestStorage . run ( undefined , onError , error ) ;
0 commit comments