@@ -74,7 +74,7 @@ class Module {
74
74
_readSourceCodePromise : Promise < string > ;
75
75
_readPromises : Map < string , Promise < ReadResult > > ;
76
76
77
- static _useGlobalCache : boolean ;
77
+ static _globalCacheRetries : number ;
78
78
79
79
constructor ( {
80
80
file,
@@ -235,21 +235,23 @@ class Module {
235
235
callback : ( error : ?Error , result : ?TransformedCode ) = > void ,
236
236
) {
237
237
const globalCache = GlobalTransformCache . get ( ) ;
238
- if ( ! Module . _useGlobalCache || globalCache == null ) {
238
+ if ( Module . _globalCacheRetries <= 0 || globalCache == null ) {
239
239
this . _transformCodeForCallback ( cacheProps , callback ) ;
240
240
return ;
241
241
}
242
242
globalCache . fetch ( cacheProps , ( globalCacheError , globalCachedResult ) => {
243
- if ( globalCacheError != null && Module . _useGlobalCache ) {
243
+ if ( globalCacheError != null && Module . _globalCacheRetries > 0 ) {
244
244
console . log ( chalk . red (
245
245
'\nWarning: the global cache failed with error:' ,
246
246
) ) ;
247
247
console . log ( chalk . red ( globalCacheError . stack ) ) ;
248
- console . log ( chalk . red (
249
- 'The global cache will be DISABLED for the ' +
250
- 'remainder of the transformation.' ,
251
- ) ) ;
252
- Module . _useGlobalCache = false ;
248
+ Module . _globalCacheRetries -- ;
249
+ if ( Module . _globalCacheRetries <= 0 ) {
250
+ console . log ( chalk . red (
251
+ 'No more retries, the global cache will be disabled for the ' +
252
+ 'remainder of the transformation.' ,
253
+ ) ) ;
254
+ }
253
255
}
254
256
if ( globalCacheError != null || globalCachedResult == null ) {
255
257
this . _transformCodeForCallback ( cacheProps , callback ) ;
@@ -353,7 +355,7 @@ class Module {
353
355
}
354
356
}
355
357
356
- Module . _useGlobalCache = true ;
358
+ Module . _globalCacheRetries = 4 ;
357
359
358
360
// use weak map to speed up hash creation of known objects
359
361
const knownHashes = new WeakMap ( ) ;
0 commit comments