7

My apps use promises (using the Lax library) quite heavily and I have seen that different callbacks often produce their own log in the Dev Console.

Does this mean that:

  1. Each callback gets its own transaction / scope?
  2. Each one gets new Governor limits?
  3. I can do much more on a Lightning page that on a Visulforce page limit-wise?

If the answer is not a clear Yes or No, what do I need to take care of if I want my callbacks to be really atomic and seperated?

1

Each Callback will not get there own limits.

The framework queues up actions before sending them to the server. This mechanism is largely transparent to you when you’re writing code but it enables the framework to minimize network traffic by batching multiple actions into one request (XHR)

So if 2 actions are queued together then these 2 will get there total limit as Govenor limit in one transaction.

There is no direct solution if you want your actions to be atomic. If you are calling only 2 actions at a time then you can set one as background action then 2 will be in different transaction.

But if there are multiple actions then only option is to wait for reply of first callback then call 2nd action. This method will be slow. You can look into this blog for a solution"https://medium.com/manj-force/did-a-enqueueaction-action-grouped-your-actions-f33ce710f0e3".

5

Might want to review this: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/controllers_server_background_actions.htm

It talks about batching and queuing of actions. Note that in the optional background mode, Don’t rely on each background action being sent in its own request as that behavior isn’t guaranteed and it can lead to performance issues. Remember that the motivation for background actions is to isolate long-running requests into a separate request to avoid slowing the response for foreground actions.

In general one event loop in Lightning sees multiple foreground actions queued into one Apex call and I think this may mean sharing governor limits. But by nature a front-end callback method is only fired after the Apex transaction is over, so yes any new call to Apex is in a new transaction with new governor limits.

Limit wise, you're mainly dealing with the boundaries of the browser and Locker Service. However when calling to Apex you do have a request payload limit of 4MB: https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/controllers_server_actions_call.htm

The main reason for the Visualforce limits is that VF posts the entire view state back and forth with every little request. In Lightning you only send as much back and forth as you define.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.