1

We tried to use it in our LWC async/await but it is not working only on Firefox. Here is a simple example. On the Firefox this alert doesn't show.

async init() {
    let promise = new Promise((resolve, reject) => {
        setTimeout(() => resolve("done!"), 1000)
      });
    
      let result = await promise; // wait until the promise resolves (*)
    
      alert(result); // "done!"
  }

  connectedCallback() {
    this.init();

What is wrong with Firefox?

4
  • 3
    I tried above code and it worked on Firefox version : 113.0.2
    – Rohit
    Sep 22, 2023 at 11:17
  • @Rohit interesting, in my case this is not working. can be that async/await is broken because of some different code? but from the other side what about LWC separation?
    – hsd
    Sep 22, 2023 at 19:04
  • @Rohit do you test it in LWC which extends NavigationMixin(LightningElement)
    – hsd
    Sep 23, 2023 at 9:15
  • It works with NavigationMixin as well. I think there is some other error before this line is getting executed. Can you add the complete code ?
    – Rohit
    Sep 23, 2023 at 11:09

1 Answer 1

0

Kind of an old thread, but there are two possible causes I can see for this issue.

  1. Do you have the setting "Use Lightning Web Security for Lightning Web Components and Aura Components" turned on in your organization? It is under the Session Settings in Setup I think? ref : https://help.salesforce.com/s/articleView?id=release-notes.rn_lc_lws.htm&release=244&type=5

  2. Are you running this component in Lightning Web Runtime community site? There used to be limitations specific to the version of Lightning Web Security that was running in LWR.

Those two could be the issue, try your component without LWS enabled, and try it somewhere else than LWR maybe?

You must log in to answer this question.

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