Skip to content

fix: handle +100K comps when resolving from org W-17876861 - #1511

Merged
shetzel merged 8 commits into
mainfrom
cd/manifest-tons-of-metadata
Feb 26, 2025
Merged

shetzel merged 8 commits into
mainfrom
cd/manifest-tons-of-metadata

Conversation

@cristiand391

@cristiand391 cristiand391 commented Feb 24, 2025 •

Copy link
Copy Markdown
Contributor

What does this PR do?

What issues does this PR fix or reference?

forcedotcom/cli#3197
@W-17876861@

Functionality Before

Trying to list +100K components from an org would throw Maximum call stack size exceeded.
Generating a manifest from an org with ~160K components (only Group and Role):

➜  dreamhouse-lwc git:(main) ✗ sf org list metadata --metadata-type Group --json | jq '.result | length'
 ›   Warning: @salesforce/plugin-deploy-retrieve is a linked ESM module and cannot be auto-transpiled. Existing compiled source will be used instead.
100001
➜  dreamhouse-lwc git:(main) ✗ sf org list metadata --metadata-type Role --json | jq '.result | length'
➜  dreamhouse-lwc git:(main) ✗ sf org list metadata --metadata-type Role --json | jq '.result | length'
59084
➜  dreamhouse-lwc git:(main) ✗ sf project generate manifest --from-org <customer-org> --metadata Group,Role
Error (1): Maximum call stack size exceeded
                                                                                                                                                                        
Warning: The input format for array arguments has changed. Use this format: --array-flag value1 --array-flag value2 --array-flag value3
➜  dreamhouse-lwc git:(main) ✗

Functionality After

handle +100K records:

➜  dreamhouse-lwc git:(main) ✗ time sf project generate manifest --from-org <customer-org> --metadata Group,Role
 ›   Warning: @salesforce/plugin-deploy-retrieve is a linked ESM module and cannot be auto-transpiled. Existing compiled source will be used instead.
successfully wrote package.xml
Warning: The input format for array arguments has changed. Use this format: --array-flag value1 --array-flag value2 --array-flag value3
sf project generate manifest --from-org <customer-org> --metadat  32.49s user 20.28s system 222% cpu 23.760 total
➜  dreamhouse-lwc git:(main) ✗ wc -l package.xml
  159095 package.xml

and default 500 batch limit allows to generate a full ~200K manifest from org without excluding any type:

➜  dreamhouse-lwc git:(main) ✗ time sf project generate manifest --from-org <customer-org>
 ›   Warning: @salesforce/plugin-deploy-retrieve is a linked ESM module and cannot be auto-transpiled. Existing compiled source will be used instead.
successfully wrote package.xml
sf project generate manifest --from-org <customer-org>  41.15s user 26
.60s system 56% cpu 1:59.90 total
➜  dreamhouse-lwc git:(main) ✗ wc -l package.xml
  219082 package.xml

Top 15 metadata sorted by qty in customer org:

"Group | 100001"
"Role | 59084"
"CustomMetadata | 12941"
"ApexClass | 6658"
"CustomObjectTranslation | 5783"
"FieldSrcTrgtRelationship | 2665"
" | 2628" :wat:
"Layout | 1116"
"CustomObject | 1026"
"Queue | 974"
"QuickAction | 948"
"AuraDefinitionBundle | 903"
"ReportFolder | 846"
"TopicsForObjects | 494"
"StaticResource | 488"

@cristiand391
cristiand391 requested a review from a team as a code owner February 24, 2025 22:17

@WillieRuemmele WillieRuemmele left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🏆

@cristiand391
cristiand391 force-pushed the cd/manifest-tons-of-metadata branch from 221e079 to b4f2b96 Compare February 25, 2025 13:52
if (mdType.name === registry.getRegistry().types.standardvalueset.name) {
shouldQueryStandardValueSets = true;
return [];
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

kinda unrelated change and doesn't have any perf impact, just simplified this b/c currying always makes it annoying to jump into funcs when attaching a debugger and didn't seem needed.


const metadataListStub = $$.SANDBOX.stub(connection.metadata, 'list');

const classesQty = 200_000;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

120K is enough to get this UT fail on my macbook but was passing on GHA runners, had to increase to 200K to get it fail 🤷🏼

@cristiand391

Copy link
Copy Markdown
Contributor Author

@shetzel please squash-merge this if it looks good, there's a bunch of commits here 😁

@shetzel
shetzel merged commit 7b2207b into main Feb 26, 2025
@shetzel
shetzel deleted the cd/manifest-tons-of-metadata branch February 26, 2025 23:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants