function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mike O.Mike O. 

How to handle action state “INCOMPLETE”

Salesforce documentation about Calling a Server-Side Action (https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/controllers_server_actions_call.htm) has an example that contains:
 
if (state === "SUCCESS") {
 .......
        }
        else if (state === "INCOMPLETE") {
            // do something
        }
        else if (state === "ERROR") {
 ......
What should "do something" be?

I've seen so many examples with "do something", including the code I've been writing, that I'd thought I should stop doing this (copy/paste) and do something about it, pun intended.
 
Best Answer chosen by Mike O.
Ajay K DubediAjay K Dubedi
Hi Mike,
Status is usually INCOMPLETE when server didn’t return a response. The server might be down or the client might be offline. The framework guarantees that an action’s callback is always invoked as long as the component is valid. If the socket to the server is never successfully opened or closes abruptly, or any other network error occurs, the XHR resolves and the callback is invoked with state equal to INCOMPLETE.

In place of //do something you can simply give an Error Message like "Server could not be reached. Check your internet connection".That's it.


I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi