Apex code is approaching a governor limit warning email
Salesforce sent your team an email saying Apex is approaching a governor limit (typically 80% of CPU, SOQL, DML, or callout caps) but didn't fail. This is an early warning — investigate before it becomes a hard limit failure.
Also seen asgovernor limit warning email·Apex governor warning·approaching governor limit·Apex limit notification email
The platform sends "Apex Governor Limit Warning" emails when a transaction uses ≥80% of a governor cap without exceeding it. The email goes to:
- The org's defined Apex Exception Email recipients (Setup → Apex Exception Email)
- The user who triggered the transaction, if they have the relevant notification preference on
The transaction itself succeeded — but you're one user-action away from a hard failure.
Reading the email
Apex resource limit warning
Class: AccountTriggerHandler
Method: bulkProcess
SOQL queries: 81 of 100 (81%)
CPU time: 8200 ms of 10000 ms (82%)
Each line is one cap. The percentages tell you which is closest to the edge.
Fix the worst one first
Look at which cap is closest to 100%. That's the one that'll blow first. Common patterns:
| Closest cap | Likely cause | Fix |
|---|---|---|
| SOQL queries | Loop with query inside | Lift query out, see SOQL 101 |
| CPU time | Nested loops / heavy computation | Bulkify, cache describes, see CPU limit |
| DML statements | Loop with DML inside | Collect + DML once, see DML 151 |
| Heap | Big query results held in memory | Stream with SOQL for-loop, see heap |
| Query rows | Unbounded SELECT | Add LIMIT or filter, see query rows |
Don't ignore the email
These warnings precede outages. A trigger at 82% on a normal day will hit 110% the day someone bulk-imports 5x more data. Treat warnings as bug reports, not noise.
Set up dedicated alerting
The default email goes to one address. For team visibility, route to:
- A Slack channel via a webhook or the
Apex Exception Emailintegration - PagerDuty for after-hours
- A Salesforce Custom Object that you query to dashboard
Sample router:
@InvocableMethod
public static void notifySlack(List<Apex_Error_Log__c> logs) {
for (Apex_Error_Log__c log : logs) {
// POST to Slack webhook with the log details
}
}
Suppress the warnings (last resort)
If a specific code path is genuinely high-load and the warning is noise:
Setup → Apex Exception Email → uncheck for that user. Or add a try/catch that logs to a custom table without the auto-email.
But: don't suppress until you've reviewed what is approaching the cap. The platform sends warnings for a reason.
A common cause: trigger fan-out
A trigger that does N queries × M records per record runs at near-cap with normal data and crashes with bulk loads. Always test triggers with 200 records at minimum (the bulk trigger size) to catch this in testing instead of production.
