Skip to content

Commit

Permalink
fix: scratch creation partial success
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Jun 14, 2024
1 parent b51f2a6 commit 74f9e1b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
28 changes: 14 additions & 14 deletions src/org/scratchOrgCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,17 +287,25 @@ export const scratchOrgCreate = async (options: ScratchOrgCreateOptions): Promis
retry: retry || 0,
});

// we'll need this scratch org connection later;
const scratchOrg = await Org.create({
aliasOrUsername: soi.Username ?? soi.SignupUsername,
// anything after this point (org is created and auth'd) is potentially recoverable with the resume scratch command.
process.exitCode = 68;

await scratchOrgAuthInfo.handleAliasAndDefaultSettings({
...{
alias,
setDefault,
setDefaultDevHub: false,
setTracksSource: tracksSource === false ? false : true,
},
});

// we'll need this scratch org connection later;
const scratchOrg = await Org.create({ aliasOrUsername: soi.Username ?? soi.SignupUsername });
const username = scratchOrg.getUsername();
logger.debug(`scratch org username ${username}`);

await emit({ stage: 'deploy settings', scratchOrgInfo: soi });

const configAggregator = await ConfigAggregator.create();

const [authInfo] = await Promise.all([
resolveUrl(scratchOrgAuthInfo),
deploySettings(
Expand All @@ -311,18 +319,10 @@ export const scratchOrgCreate = async (options: ScratchOrgCreateOptions): Promis
),
]);

await scratchOrgAuthInfo.handleAliasAndDefaultSettings({
...{
alias,
setDefault,
setDefaultDevHub: false,
setTracksSource: tracksSource === false ? false : true,
},
});
cache.unset(scratchOrgInfoId);
const authFields = authInfo.getFields();
await Promise.all([emit({ stage: 'done', scratchOrgInfo: soi }), cache.write(), emitPostOrgCreate(authFields)]);

process.exitCode = 0;
return {
username,
scratchOrgInfo: soi,
Expand Down
14 changes: 8 additions & 6 deletions src/org/scratchOrgInfoApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ export const deploySettings = async (
};

/**
* Makes sure the scratch org's instanceUrl is resolvable (that is, DNS is ready)
*
* @param scratchOrgAuthInfo an AuthInfo class from the scratch org
* @returns AuthInfo
Expand All @@ -435,13 +436,14 @@ export const resolveUrl = async (scratchOrgAuthInfo: AuthInfo): Promise<AuthInfo
const logger = await Logger.child('scratchOrgInfoApi-resolveUrl');
const { instanceUrl } = scratchOrgAuthInfo.getFields();
if (!instanceUrl) {
const sfError = new SfError('Org does not have instanceUrl');
sfError.setData({
orgId: scratchOrgAuthInfo.getFields().orgId,
username: scratchOrgAuthInfo.getFields().username,
instanceUrl,
throw SfError.create({
message: 'Org does not have instanceUrl',
data: {
orgId: scratchOrgAuthInfo.getFields().orgId,
username: scratchOrgAuthInfo.getFields().username,
instanceUrl,
},
});
throw sfError;
}
logger.debug(`processScratchOrgInfoResult - resultData.instanceUrl: ${instanceUrl}`);
const options = {
Expand Down

2 comments on commit 74f9e1b

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger Benchmarks - ubuntu-latest

Benchmark suite Current: 74f9e1b Previous: 8235d7b Ratio
Child logger creation 457457 ops/sec (±1.99%) 463833 ops/sec (±1.37%) 1.01
Logging a string on root logger 771872 ops/sec (±10.67%) 760128 ops/sec (±6.98%) 0.98
Logging an object on root logger 572567 ops/sec (±10.13%) 556880 ops/sec (±8.82%) 0.97
Logging an object with a message on root logger 7566 ops/sec (±205.24%) 8740 ops/sec (±202.25%) 1.16
Logging an object with a redacted prop on root logger 494612 ops/sec (±6.77%) 420242 ops/sec (±10.19%) 0.85
Logging a nested 3-level object on root logger 372959 ops/sec (±6.80%) 367334 ops/sec (±5.69%) 0.98

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logger Benchmarks - windows-latest

Benchmark suite Current: 74f9e1b Previous: 8235d7b Ratio
Child logger creation 319989 ops/sec (±0.95%) 341491 ops/sec (±3.36%) 1.07
Logging a string on root logger 714523 ops/sec (±7.13%) 794113 ops/sec (±4.67%) 1.11
Logging an object on root logger 608048 ops/sec (±5.20%) 607691 ops/sec (±5.16%) 1.00
Logging an object with a message on root logger 6743 ops/sec (±203.34%) 4563 ops/sec (±210.28%) 0.68
Logging an object with a redacted prop on root logger 482009 ops/sec (±6.18%) 402262 ops/sec (±11.22%) 0.83
Logging a nested 3-level object on root logger 347842 ops/sec (±5.09%) 321764 ops/sec (±5.00%) 0.93

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.