Skip to content

Commit

Permalink
fix: move env vars to myDomainResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Feb 17, 2021
1 parent 2e2cb84 commit fcf1a4a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
8 changes: 1 addition & 7 deletions src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
import { URL } from 'url';
import { Duration, maxBy, merge, Env } from '@salesforce/kit';
import { maxBy, merge } from '@salesforce/kit';
import { asString, ensure, getNumber, isString, JsonCollection, JsonMap, Optional } from '@salesforce/ts-types';
import {
Connection as JSForceConnection,
Expand Down Expand Up @@ -39,10 +39,6 @@ export const SFDX_HTTP_HEADERS = {
};

export const DNS_ERROR_NAME = 'Domain Not Found';
// Timeout for DNS lookup polling defaults to 3 seconds and should always be at least 3 seconds
const DNS_TIMEOUT = Math.max(3, new Env().getNumber('SFDX_DNS_TIMEOUT', 3) as number);
// Retry frequency for DNS lookup polling defaults to 1 second and should be at least 1 second
const DNS_RETRY_FREQ = Math.max(1, new Env().getNumber('SFDX_DNS_RETRY_FREQUENCY', 1) as number);

// This interface is so we can add the autoFetchQuery method to both the Connection
// and Tooling classes and get nice typing info for it within editors. JSForce is
Expand Down Expand Up @@ -222,8 +218,6 @@ export class Connection extends JSForceConnection {
}
const resolver = await MyDomainResolver.create({
url: new URL(this.options.connectionOptions.instanceUrl),
timeout: Duration.seconds(DNS_TIMEOUT),
frequency: Duration.seconds(DNS_RETRY_FREQ),
});
try {
await resolver.resolve();
Expand Down
9 changes: 7 additions & 2 deletions src/status/myDomainResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ import { sfdc } from '../util/sfdc';
import { StatusResult } from './client';
import { PollingClient } from './pollingClient';

// Timeout for DNS lookup polling defaults to 3 seconds and should always be at least 3 seconds
const DNS_TIMEOUT = Math.max(3, new Env().getNumber('SFDX_DNS_TIMEOUT', 3) as number);
// Retry frequency for DNS lookup polling defaults to 1 second and should be at least 1 second
const DNS_RETRY_FREQ = Math.max(1, new Env().getNumber('SFDX_DNS_RETRY_FREQUENCY', 1) as number);

/**
* A class used to resolve MyDomains. After a ScratchOrg is created it's host name my not be propagated to the
* Salesforce DNS service. This service is not exclusive to Salesforce My Domain URL and could be used for any hostname.
Expand Down Expand Up @@ -95,8 +100,8 @@ export class MyDomainResolver extends AsyncOptionalCreatable<MyDomainResolver.Op
};
}
},
timeout: this.options.timeout || Duration.seconds(30),
frequency: this.options.frequency || Duration.seconds(10),
timeout: this.options.timeout || Duration.seconds(DNS_TIMEOUT),
frequency: this.options.frequency || Duration.seconds(DNS_RETRY_FREQ),
timeoutErrorName: 'MyDomainResolverTimeoutError',
};
const client = await PollingClient.create(pollingOptions);
Expand Down

0 comments on commit fcf1a4a

Please sign in to comment.