@salesforce/core 2.35.1 → 2.35.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/lib/lifecycleEvents.js +1 -1
- package/lib/scratchOrgErrorCodes.d.ts +1 -1
- package/lib/scratchOrgErrorCodes.js +3 -0
- package/lib/scratchOrgInfoApi.d.ts +0 -1
- package/lib/scratchOrgInfoApi.js +44 -20
- package/lib/scratchOrgSettingsGenerator.js +1 -1
- package/lib/status/pollingClient.d.ts +1 -1
- package/lib/status/pollingClient.js +11 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [2.35.2](https://github.com/forcedotcom/sfdx-core/compare/v2.35.1...v2.35.2) (2022-02-16)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- network error tolerance ([#517](https://github.com/forcedotcom/sfdx-core/issues/517)) ([676ebfe](https://github.com/forcedotcom/sfdx-core/commit/676ebfe58b13826b53f461b2fef321c21f583004))
|
|
10
|
+
- remove redundant warnings about no listerners on warnings ([7a5bd23](https://github.com/forcedotcom/sfdx-core/commit/7a5bd2390713da929e886f41d9dcbc811104f99a))
|
|
11
|
+
|
|
5
12
|
### [2.35.1](https://github.com/forcedotcom/sfdx-core/compare/v2.35.0...v2.35.1) (2022-02-10)
|
|
6
13
|
|
|
7
14
|
### Bug Fixes
|
package/lib/lifecycleEvents.js
CHANGED
|
@@ -170,7 +170,7 @@ class Lifecycle {
|
|
|
170
170
|
*/
|
|
171
171
|
async emit(eventName, data) {
|
|
172
172
|
const listeners = this.getListeners(eventName);
|
|
173
|
-
if (listeners.length === 0) {
|
|
173
|
+
if (listeners.length === 0 && eventName !== Lifecycle.warningEventName) {
|
|
174
174
|
this.debug(`A lifecycle event with the name ${eventName} does not exist. An event must be registered before it can be emitted.`);
|
|
175
175
|
}
|
|
176
176
|
else {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Optional } from '@salesforce/ts-types';
|
|
2
2
|
import { Logger } from './logger';
|
|
3
3
|
import { ScratchOrgInfo } from './scratchOrgInfoApi';
|
|
4
|
-
export declare const checkScratchOrgInfoForErrors: (orgInfo: ScratchOrgInfo
|
|
4
|
+
export declare const checkScratchOrgInfoForErrors: (orgInfo: Optional<ScratchOrgInfo>, hubUsername: Optional<string>, logger: Logger) => ScratchOrgInfo;
|
|
@@ -29,6 +29,9 @@ const optionalErrorCodeMessage = (errorCode, args) => {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
const checkScratchOrgInfoForErrors = (orgInfo, hubUsername, logger) => {
|
|
32
|
+
if (!orgInfo) {
|
|
33
|
+
throw new sfdxError_1.SfdxError('No scratch org info found.', 'ScratchOrgInfoNotFound');
|
|
34
|
+
}
|
|
32
35
|
if (orgInfo.Status === 'Active') {
|
|
33
36
|
return orgInfo;
|
|
34
37
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Optional } from '@salesforce/ts-types';
|
|
2
2
|
import { Duration } from '@salesforce/kit';
|
|
3
3
|
import { RecordResult } from 'jsforce';
|
|
4
|
-
import { retry } from 'ts-retry-promise';
|
|
5
4
|
import { Org } from './org';
|
|
6
5
|
import { AuthInfo } from './authInfo';
|
|
7
6
|
import SettingsGenerator, { ObjectSetting } from './scratchOrgSettingsGenerator';
|
package/lib/scratchOrgInfoApi.js
CHANGED
|
@@ -18,6 +18,7 @@ const authInfo_1 = require("./authInfo");
|
|
|
18
18
|
const messages_1 = require("./messages");
|
|
19
19
|
const sfdxError_1 = require("./sfdxError");
|
|
20
20
|
const sfdcUrl_1 = require("./util/sfdcUrl");
|
|
21
|
+
const pollingClient_1 = require("./status/pollingClient");
|
|
21
22
|
const myDomainResolver_1 = require("./status/myDomainResolver");
|
|
22
23
|
const scratchOrgErrorCodes_1 = require("./scratchOrgErrorCodes");
|
|
23
24
|
messages_1.Messages.importMessagesDirectory(__dirname);
|
|
@@ -251,30 +252,53 @@ const pollForScratchOrgInfo = async (hubOrg, scratchOrgInfoId,
|
|
|
251
252
|
timeout = kit_1.Duration.minutes(15)) => {
|
|
252
253
|
const logger = await logger_1.Logger.child('scratchOrgInfoApi-pollForScratchOrgInfo');
|
|
253
254
|
logger.debug(`PollingTimeout in minutes: ${timeout.minutes}`);
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
255
|
+
const pollingOptions = {
|
|
256
|
+
async poll() {
|
|
257
|
+
try {
|
|
258
|
+
const resultInProgress = await hubOrg
|
|
259
|
+
.getConnection()
|
|
260
|
+
.sobject('ScratchOrgInfo')
|
|
261
|
+
.retrieve(scratchOrgInfoId);
|
|
262
|
+
logger.debug(`polling client result: ${JSON.stringify(resultInProgress, null, 4)}`);
|
|
263
|
+
// Once it's "done" we can return it
|
|
264
|
+
if (resultInProgress.Status === 'Active' || resultInProgress.Status === 'Error') {
|
|
265
|
+
return {
|
|
266
|
+
completed: true,
|
|
267
|
+
payload: resultInProgress,
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
logger.debug(`Scratch org status is ${resultInProgress.Status}`);
|
|
271
|
+
return {
|
|
272
|
+
completed: false,
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
catch (error) {
|
|
276
|
+
logger.debug(`An error occurred trying to retrieve scratchOrgInfo for ${scratchOrgInfoId}`);
|
|
277
|
+
logger.debug(`Error: ${error.message}`);
|
|
278
|
+
logger.debug('Re-trying deploy check again....');
|
|
279
|
+
return {
|
|
280
|
+
completed: false,
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
timeout,
|
|
285
|
+
frequency: kit_1.Duration.seconds(1),
|
|
286
|
+
timeoutErrorName: 'ScratchOrgInfoTimeoutError',
|
|
287
|
+
};
|
|
288
|
+
const client = await pollingClient_1.PollingClient.create(pollingOptions);
|
|
289
|
+
try {
|
|
290
|
+
const resultInProgress = await client.subscribe();
|
|
291
|
+
return scratchOrgErrorCodes_1.checkScratchOrgInfoForErrors(resultInProgress, hubOrg.getUsername(), logger);
|
|
292
|
+
}
|
|
293
|
+
catch (error) {
|
|
294
|
+
const err = error;
|
|
295
|
+
if (err.message) {
|
|
296
|
+
throw sfdxError_1.SfdxError.wrap(err);
|
|
263
297
|
}
|
|
264
|
-
// all other statuses, OR lack of status (e.g. network errors) will cause a retry
|
|
265
|
-
throw new sfdxError_1.SfdxError(`Scratch org status is ${resultInProgress.Status}`);
|
|
266
|
-
}, {
|
|
267
|
-
retries: 'INFINITELY',
|
|
268
|
-
timeout: timeout.milliseconds,
|
|
269
|
-
delay: kit_1.Duration.seconds(2).milliseconds,
|
|
270
|
-
backoff: 'LINEAR',
|
|
271
|
-
maxBackOff: kit_1.Duration.seconds(30).milliseconds,
|
|
272
|
-
}).catch(() => {
|
|
273
298
|
throw new sfdxError_1.SfdxError(`The scratch org did not complete within ${timeout.minutes} minutes`, 'orgCreationTimeout', [
|
|
274
299
|
'Try your force:org:create command again with a longer --wait value',
|
|
275
300
|
]);
|
|
276
|
-
}
|
|
277
|
-
return scratchOrgErrorCodes_1.checkScratchOrgInfoForErrors(response, hubOrg.getUsername(), logger);
|
|
301
|
+
}
|
|
278
302
|
};
|
|
279
303
|
exports.pollForScratchOrgInfo = pollForScratchOrgInfo;
|
|
280
304
|
/**
|
|
@@ -101,7 +101,7 @@ class SettingsGenerator {
|
|
|
101
101
|
timeoutErrorName: 'DeployingSettingsTimeoutError',
|
|
102
102
|
};
|
|
103
103
|
const client = await pollingClient_1.PollingClient.create(pollingOptions);
|
|
104
|
-
const status =
|
|
104
|
+
const status = await client.subscribe();
|
|
105
105
|
if (status !== RequestStatus.Succeeded) {
|
|
106
106
|
const componentFailures = ts_types_1.ensureObject(result.details).componentFailures;
|
|
107
107
|
const failures = (Array.isArray(componentFailures) ? componentFailures : [componentFailures])
|
|
@@ -38,7 +38,7 @@ export declare class PollingClient extends AsyncOptionalCreatable<PollingClient.
|
|
|
38
38
|
* Returns a promise to call the specified polling function using the interval and timeout specified
|
|
39
39
|
* in the polling options.
|
|
40
40
|
*/
|
|
41
|
-
subscribe(): Promise<
|
|
41
|
+
subscribe<T = AnyJson>(): Promise<T | undefined>;
|
|
42
42
|
}
|
|
43
43
|
export declare namespace PollingClient {
|
|
44
44
|
/**
|
|
@@ -12,6 +12,7 @@ const ts_types_1 = require("@salesforce/ts-types");
|
|
|
12
12
|
const ts_retry_promise_1 = require("ts-retry-promise");
|
|
13
13
|
const logger_1 = require("../logger");
|
|
14
14
|
const sfdxError_1 = require("../sfdxError");
|
|
15
|
+
const lifecycleEvents_1 = require("../lifecycleEvents");
|
|
15
16
|
/**
|
|
16
17
|
* This is a polling client that can be used to poll the status of long running tasks. It can be used as a replacement
|
|
17
18
|
* for Streaming when streaming topics are not available or when streaming handshakes are failing. Why wouldn't you
|
|
@@ -51,6 +52,7 @@ class PollingClient extends kit_1.AsyncOptionalCreatable {
|
|
|
51
52
|
* Returns a promise to call the specified polling function using the interval and timeout specified
|
|
52
53
|
* in the polling options.
|
|
53
54
|
*/
|
|
55
|
+
// TODO v3.0 remove undefined as this method ensures that the payload is always returned
|
|
54
56
|
async subscribe() {
|
|
55
57
|
var _a;
|
|
56
58
|
let errorInPollingFunction; // keep this around for returning in the catch block
|
|
@@ -60,11 +62,18 @@ class PollingClient extends kit_1.AsyncOptionalCreatable {
|
|
|
60
62
|
result = await this.options.poll();
|
|
61
63
|
}
|
|
62
64
|
catch (error) {
|
|
63
|
-
errorInPollingFunction = error;
|
|
65
|
+
const err = (errorInPollingFunction = error);
|
|
66
|
+
if (['ETIMEDOUT', 'ENOTFOUND', 'ECONNRESET', 'socket hang up'].some((retryableNetworkError) => err.message.includes(retryableNetworkError))) {
|
|
67
|
+
this.logger.debug('Network error on the request', err);
|
|
68
|
+
await lifecycleEvents_1.Lifecycle.getInstance().emitWarning('Network error occurred. Continuing to poll.');
|
|
69
|
+
throw sfdxError_1.SfdxError.wrap(err);
|
|
70
|
+
}
|
|
64
71
|
// there was an actual error thrown, so we don't want to keep retrying
|
|
65
|
-
throw new ts_retry_promise_1.NotRetryableError(
|
|
72
|
+
throw new ts_retry_promise_1.NotRetryableError(err.name);
|
|
66
73
|
}
|
|
67
74
|
if (result.completed) {
|
|
75
|
+
// TODO v3.0: payload should be of type T always so that
|
|
76
|
+
// consumers get the same type in return.
|
|
68
77
|
return result.payload;
|
|
69
78
|
}
|
|
70
79
|
throw new Error('Operation did not complete. Retrying...'); // triggers a retry
|