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
Rashmi JainRashmi Jain 

Error: Too many Future Calls in Production

Hi,

 

My Test class is giving Too Many Future Calls Exception in Production Environment though it worked fine in the TEST environment (i.e. without any failure).

While deploying to production the test class is throwing

System.LimitException : Too many future calls :11

 

I have checked the number of times future method is called, it is less than 10 for each test method (So it wasn't giving any failure in TEST env.)

 

What may be the reason of the failure coming in Production Enviroment specifically?

craigmhcraigmh

More data would. For example, this could blow up in Production with 100+ users, but could work in a Sandbox with only a few users. I used SOQL queries instead of Future Calls, but the principle is the same.

 

List<User> users = [Select Id, Name From User];
for(User u: users) {
   u.Name = u.Name + ' ' + u.Id;
   update u;
}

 

Rashmi JainRashmi Jain

The large amount of data does give "Too many SOQL queries" error because the query might be retrieveing a large amount of data.

But, is that applicable for "Too many FUTURE CALLS" error also?

I am passing a List of Ids in my future method.

craigmhcraigmh

If you're doing future calls inside a loop, the principle idea is the same.