Skip to content

Commit

Permalink
fix: retry on net errors when retrieving MD info
Browse files Browse the repository at this point in the history
  • Loading branch information
cristiand391 committed Mar 28, 2023
1 parent c026e51 commit 16b03c9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/resolve/connectionResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/

import { Connection, Logger } from '@salesforce/core';
import { ensureArray } from '@salesforce/kit';
import { StatusResult, PollingClient, Connection, Logger } from '@salesforce/core';
import { Duration, ensureArray } from '@salesforce/kit';
import { retry, NotRetryableError, RetryError } from 'ts-retry-promise';
import { RegistryAccess, registry as defaultRegistry, MetadataType } from '../registry';
import { standardValueSet } from '../registry/standardvalueset';
Expand Down Expand Up @@ -92,8 +92,18 @@ export class ConnectionResolver {
private async listMembers(query: ListMetadataQuery): Promise<FileProperties[]> {
let members: FileProperties[];

const pollingOptions: PollingClient.Options = {
frequency: Duration.milliseconds(1000),
timeout: Duration.minutes(1),
poll: async (): Promise<StatusResult> => {
const res = ensureArray(await this.connection.metadata.list(query));
return { completed: true, payload: res };
},
};

const pollingClient = await PollingClient.create(pollingOptions);
try {
members = ensureArray((await this.connection.metadata.list(query)) as FileProperties[]);
members = await pollingClient.subscribe();
} catch (error) {
this.logger.debug((error as Error).message);
members = [];
Expand Down

0 comments on commit 16b03c9

Please sign in to comment.