I have an Apex call which causes an error (ENTITY_IS_DELETED, but it doesn't matter which error it is). I might be able to fix that error, but now it somehow also returns successfully anyway, so the client is confused.

Both the server and the client seem off, as follows.

// MyClass
public static void apexCall()
    // some code
    // --> generates error
    // return true; // -> Returns true anyways! This is the problem

In LWC, I call Apex. Now it catches the error, but then still proceeds to read the result anyway, which it shouldn't! It should stop.

console.log( '1' );

apexCall( { 
    var1: myVar
} ).then((result) =>
    console.log( '2 ' + result );

    // ..
.catch((error) =>
    log( 'x', this );

    console.error( error );

The log goes unexpectedly from the error to logging the new result (true):

2 true

Screenshot from live situation (using different numbers)

enter image description here

  • It's literally impossible for this code to behave in the manner you've described here, because promises can not both resolve and reject. We'll need to see a more concrete example (see SSCCE).
    – sfdcfox
    Commented May 21 at 10:01
  • @sfdcfox I added a screenshot which shows the situation happening in real life.
    – Z0q
    Commented May 21 at 10:06
  • Can you check from the debug logs, if any record is getting deleted in the same transaction, I had faced similar kind of issue, but there was no LWC involved. Or can you check if server side calling is happening multiple times or not. Commented May 21 at 10:17
  • There's something else going on that you've missed. A single promise can't both resolve and reject. Proof: new Promise((a,b)=>(a(1),b(2))).then(console.log).catch(console.error). The logical conclusion is that your code is being called twice. As such, we'll need to see some semblance of the actual code.
    – sfdcfox
    Commented May 21 at 10:18
  • @AsheshKumar Hi, and welcome to SFSE! I've converted your answer to a comment, since it does not attempt to answer the question. In time, as you gain reputation, you'll be able to add comments to posts (see privileges). In the meantime, feel free to read about How to Ask and take our quick tour. We look forward to your future contributions!
    – sfdcfox
    Commented May 21 at 10:24

1 Answer 1


As @sfdcfox pointed out, it seems indeed there was an issue that the user was able to press the button twice, with calls conflicting each other. I implemented a way to disable the button until it completed its task.

You must log in to answer this question.

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