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
Pavan Kumar 1700Pavan Kumar 1700 

Can any one help to know about the below error?

CPU TIMEOUT ERROR
Best Answer chosen by Pavan Kumar 1700
SwethaSwetha (Salesforce Developers) 
HI Pavan,
1. This error generally occurs if transactions consume too much CPU time. Salesforce has a timeout limit for transactions based on CPU usage. If transactions consume too much CPU time, Salesforce shut them down as a long-running transaction.

2. I see you have a system. debug in while loop. To fix the issue, you need to optimize the code involved following the best practices described in the below articles.

>> https://help.salesforce.com/articleView?id=000232681&language=en_US&type=1
>> https://developer.salesforce.com/page/Apex_Code_Best_Practices

3. In general it is suggested to use the following limit methods in complex code to debug the amount of CPU time currently used in the transaction:

getCpuTime()
Returns the CPU time (in milliseconds) accumulated on the Salesforce servers in the current transaction.

getLimitCpuTime()
Returns the time limit (in milliseconds) of CPU usage in the current transaction.

Related: https://salesforce.stackexchange.com/questions/319277/how-to-debug-which-process-is-slowing-my-updates explains how to debug this issue using the developer console

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you