@@ -20,7 +20,7 @@ import {
20
20
} from './cli-protocol/cc/arduino/cli/commands/v1/commands_pb' ;
21
21
import * as commandsGrpcPb from './cli-protocol/cc/arduino/cli/commands/v1/commands_grpc_pb' ;
22
22
import { NotificationServiceServer } from '../common/protocol' ;
23
- import { Deferred } from '@theia/core/lib/common/promise-util' ;
23
+ import { Deferred , retry } from '@theia/core/lib/common/promise-util' ;
24
24
import { Status as RpcStatus } from './cli-protocol/google/rpc/status_pb' ;
25
25
26
26
@injectable ( )
@@ -232,45 +232,15 @@ export class CoreClientProvider extends GrpcClientProvider<CoreClientProvider.Cl
232
232
} ) ;
233
233
}
234
234
235
- protected async updateIndexes ( {
236
- client,
237
- instance,
238
- } : CoreClientProvider . Client ) : Promise < CoreClientProvider . Client > {
239
- // in a separate promise, try and update the index
240
- let indexUpdateSucceeded = true ;
241
- for ( let i = 0 ; i < 10 ; i ++ ) {
242
- try {
243
- await this . updateIndex ( { client, instance } ) ;
244
- indexUpdateSucceeded = true ;
245
- break ;
246
- } catch ( e ) {
247
- console . error ( `Error while updating index in attempt ${ i } .` , e ) ;
248
- }
249
- }
250
- if ( ! indexUpdateSucceeded ) {
251
- console . error ( 'Could not update the index. Please restart to try again.' ) ;
252
- }
253
-
254
- let libIndexUpdateSucceeded = true ;
255
- for ( let i = 0 ; i < 10 ; i ++ ) {
256
- try {
257
- await this . updateLibraryIndex ( { client, instance } ) ;
258
- libIndexUpdateSucceeded = true ;
259
- break ;
260
- } catch ( e ) {
261
- console . error ( `Error while updating library index in attempt ${ i } .` , e ) ;
262
- }
263
- }
264
- if ( ! libIndexUpdateSucceeded ) {
265
- console . error (
266
- 'Could not update the library index. Please restart to try again.'
267
- ) ;
268
- }
269
-
270
- if ( indexUpdateSucceeded && libIndexUpdateSucceeded ) {
271
- this . notificationService . notifyIndexUpdated ( ) ;
272
- }
273
- return { client, instance } ;
235
+ protected async updateIndexes (
236
+ client : CoreClientProvider . Client
237
+ ) : Promise < CoreClientProvider . Client > {
238
+ await Promise . all ( [
239
+ retry ( ( ) => this . updateIndex ( client ) , 50 , 3 ) ,
240
+ retry ( ( ) => this . updateLibraryIndex ( client ) , 50 , 3 ) ,
241
+ ] ) ;
242
+ this . notificationService . notifyIndexUpdated ( ) ;
243
+ return client ;
274
244
}
275
245
276
246
protected async updateLibraryIndex ( {
0 commit comments