0

If open network you can see calls like this:

/aura?r=14&aura.ApexAction.execute=3

where 3 (or 1, or 2, or any other number) is apex calls count has been sent together. And it causes errors because of "uncommitted work pending"

Is there a way to send apex call requests separately?

Actually such code works, but it's definitely not expected to do things like that.

Aura.$Services$.$AuraClientService$.prototype.$setXHRExclusivity$(true) 

Full source is here: https://github.com/forcedotcom/aura/blob/cfc6f05ff3758db06dbc1e45136a7247516a634f/aura-impl/src/main/resources/aura/AuraClientService.js

2 Answers 2

2

This concept of batching apex calls together is called boxcar'ing.

You can send/receive a long running apex call separately by using setBackground

// set up the server-action action
var action = cmp.get("c.serverEcho");
// optionally set actions params
//action.setParams({ firstName : cmp.get("v.firstName") });
// set as a background action
action.setBackground();

Note: In LWC its currently not available. You can refer here

1

Check winter 2020 release notes from salesforce

Hitting Apex Limits in Server-Side Actions Is More Predictable

Apex limits in Lightning components are now applied per action. Previously, the Apex limits applied across all the actions batched together (boxcar’ed) in a request (XHR). Where: This change applies to Aura components and Lightning web components in Lightning Experience, Salesforce Classic, Lightning communities, and all versions of the Salesforce app.

so this issue that you are seeing will automatically go away after winter 2020 release.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .