Make Long-Running Callouts with Continuations

Use the Continuation class in Apex to make a long-running request to an external web service from an Aura component or a Lightning web component. Process the response in a callback method. An asynchronous callout made with a continuation doesn’t count toward the Apex limit of 10 synchronous requests that last longer than five seconds. Therefore, you can make more long-running callouts and integrate your component with a complex back-end API.

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.

How: Continuations can lead to multiple long-running actions, so be aware of these limits when using them.

Up to three callouts per continuation
A single Continuation object can contain a maximum of three callouts.
Serial processing for continuation actions
The framework processes actions containing a continuation serially from the client. The previous continuation action call must have completed before the next continuation action call is made. At any time, you can have only one continuation in progress on the client.
DML operation restrictions
An Apex method that returns a Continuation object can’t perform Data Manipulation Language (DML) operations. DML statements insert, update, merge, delete, and restore data in Salesforce. If a DML operation is performed within the continuation method, the continuation execution doesn’t proceed, the transaction is rolled back, and an error is returned.
You can perform DML operations in the Apex callback method for the continuation.