For the Salesforce packaging, there is a limit of 10,000 metadata components. We have several packages and we once reached that limit for one of the packages and had to make a lot of last-minute changes to the package failing.

We are creating an unlocked package first and then we are converting to a managed package. Is there any way, we can add some checks to the earlier threshold so that we'll have some time to gracefully handle the situation.

Looking forward to any sfdx commands,bash scripts, or any apex native ways so that we will have ourselves notified before this limit.

1 Answer 1


When you're doing a full deployment, the deployResult gives you information about the total number of components. Thus, you could actually do this in a number of ways, such as adding a commit hook to run a validation deployment without unit tests to confirm the official size, and read that data, potentially rolling back the commit with an error if a threshold is met. Note that if this managed package is an ISV product bound for the AppExchange, you won't need to worry about the 10,000 file limit, as that limit is 35,000 as of the time of this answer. Check deploy() for more information about package size limits.

  • About 35,000 limit - it says 10K is it not the same? Maximum number of files in packages 10,000
    – Ysr Shk
    Commented Mar 14 at 7:14
  • 1
    @YsrShk Maximum number of files in AppExchange packages 35,000
    – sfdcfox
    Commented Mar 14 at 13:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .