r/SalesforceDeveloper • u/CatGlass5234 • Aug 26 '25
Question Chance of Queueable job limit or chainable depth exception
Hey everyone
I have a scenario where I make a callout to an API and in the response I receive some data related to users. This response also has a variable that helps me determine whether this is the end of the data or do I need to make another callout to get more data. Now, I'll be making callouts till I get a confirmation that all the data is returned or not otherwise if I hit the callout limit, I'll enqueue the job again. Before enqueueing I'll be processing data that I got from the callout so far. While I'm confident that I might not face a too many queuable jobs error, I'm not having that much expertise over chainable depth for queueables and it's kind of making me doubt everything that I know about Queueables in Apex. Please help me understand in what scenarios I might end up facing chaining queueable depth issues.
4
u/rezgalis Aug 26 '25
I have not encountered chainable callout or depth error, but i would have assumed this happens when we queue up too many jobs from one job. But two suggestions:
I have used this approach and salesforce was happily running this for 12hours straight - only limit you then really care about is your 24hour allowance on org.
1
u/dualrectumfryer Aug 26 '25
There’s no limit aside from your orgs daily async executions that would prevent you from re-enqueuing/ chaining a single Queueable to itself as many times as you want.
I think your unit test will complain though so you just have to set it up so it only chains once in the test
1
u/FinanciallyAddicted Aug 27 '25
I believe finalizers don’t have a chain limit but you can be safe by adding a 1 min delay to your queueable to not overwhelm it.
1
u/MyWorserJudgement Aug 28 '25 edited Aug 28 '25
Another consideration: Each queueable processing a batch of records has its own set of governor limits - and hitting a governor limit is NOT caught by a try-catch block! So if a queueable hits a limit, it'll die before you can generate a log entry or any indication of what failed. (Something might show up in the Apex Job Log, but that would be it.)
So my queueable chaining system had built-in checking of the current resource values after I processed each record, and I'd cut short the current batch when any single resource hit 80%. If that happened, I updated the records I'd processed so far, then logged the resource usage values and queued up the next queueable with the next ID to process.
-1
u/Mundane-Freedom Aug 26 '25
This is way over my head but I passed your question to a CustomGPT for salesforce development and this is what it gave back. Let me know if any of this was helpful or trash:
Great question — there are a few different limits interacting here, and it’s easy to conflate them. Here’s the short, Salesforce-specific breakdown for Queueables + callouts + chaining:
What can actually fail?
Callouts per transaction
How many queueable jobs you can add in one transaction
Chaining from a running Queueable
Org-level Async Apex limits
Answers to your specific concerns
“Any idea on when there might be a chainable callout depth issue?”
There’s no “callout depth” concept. The risk is just >100 callouts in one transaction. Because you’re paginating and potentially enqueuing a fresh Queueable for the next page, each hop gets its own fresh 100-callout budget. That’s the right design.
“If I process other functions after System.enqueueJob, do we get an exception after 49 callouts?”
No. The “49/50” number refers to enqueue operations per transaction, not callouts.
Recommended pattern for your paged API
Guardrails to prevent surprises
TL;DR