File tree Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -326,18 +326,39 @@ function fetchTraceGeoData(calcData) {
326
326
}
327
327
328
328
PlotlyGeoAssets [ url ] = d ;
329
- resolve ( d ) ;
329
+ return resolve ( d ) ;
330
330
} ) ;
331
331
} ) ;
332
332
}
333
333
334
+ function wait ( url ) {
335
+ return new Promise ( function ( resolve , reject ) {
336
+ var cnt = 0 ;
337
+ var interval = setInterval ( function ( ) {
338
+ if ( PlotlyGeoAssets [ url ] && PlotlyGeoAssets [ url ] !== 'pending' ) {
339
+ clearInterval ( interval ) ;
340
+ return resolve ( PlotlyGeoAssets [ url ] ) ;
341
+ }
342
+ if ( cnt > 100 ) {
343
+ clearInterval ( interval ) ;
344
+ return reject ( 'Unexpected error while fetching from ' + url ) ;
345
+ }
346
+ cnt ++ ;
347
+ } , 50 ) ;
348
+ } ) ;
349
+ }
350
+
334
351
for ( var i = 0 ; i < calcData . length ; i ++ ) {
335
352
var trace = calcData [ i ] [ 0 ] . trace ;
336
353
var url = trace . geojson ;
337
354
338
- if ( typeof url === 'string' && ! PlotlyGeoAssets [ url ] ) {
339
- PlotlyGeoAssets [ url ] = 'pending' ;
340
- promises . push ( fetch ( url ) ) ;
355
+ if ( typeof url === 'string' ) {
356
+ if ( ! PlotlyGeoAssets [ url ] ) {
357
+ PlotlyGeoAssets [ url ] = 'pending' ;
358
+ promises . push ( fetch ( url ) ) ;
359
+ } else if ( PlotlyGeoAssets [ url ] === 'pending' ) {
360
+ promises . push ( wait ( url ) ) ;
361
+ }
341
362
}
342
363
}
343
364
You can’t perform that action at this time.
0 commit comments