function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Streamline Code to avoid "CPU Timeout" error

Our instance has a large amount of apex on a custom object and we continously run into the dreaded CPU Timeout error. Even after going to great lenghts to optimize our code by combining queries, pushing triggers to async methods, and even removing some logic we still manage to run into this error. We have also implemented a trigger framework similar to the one documented on Salesforce Dev blogs to try and cope with this. However, since we are using a trigger framework, there are a large number of class instantiations and method calls per transaction so I'm wondering if this is just adding to the problem.

My question is, what are some of the less obvious culprits that can contribute to the timeout error? And given those, what is the best way to compensate for those when writing triggers?

Any feedback is appreciated, Thanks.
Scott Haleo 4Scott Haleo 4
Hi Kdavis,

You can refer to the below link.

If you have still any questions let me know.

If you got your answer then kindly mark this as solved.

Scott Haleo