lwc icon indicating copy to clipboard operation
lwc copied to clipboard

Async await syntax is broken on Firefox

Open sinhgc opened this issue 10 months ago • 2 comments

Description

The modern async - await syntax seems broken on Firefox while using a static resource library. Please note that if I put the same code in to a LWC, it works well, but when I put it into a static resource, it's broken.

Steps to Reproduce

  • Create a simple static resource like this
const test = async () => {
    console.log('hello');
};

(async () => {
    await test();
    console.log('This line is unreachable on Firefox');
})();
  • From the LWC
import { LightningElement } from 'lwc';
import sampleLib from '@salesforce/resourceUrl/sampleLib'
import {loadScript} from 'lightning/platformResourceLoader'

export default class SampleCode extends LightningElement {
    constructor(){
        super();
        loadScript(this, sampleLib).then(()=> {
            //just do nothing
        })
    }
}

Expected Results

The line of code after the await should be reachable.

Actual Results

The line of code after the await is unreachable on Firefox.

Browsers Affected

Firefox

Version

The latest version - 134.0 (aarch64)

sinhgc avatar Jan 10 '25 07:01 sinhgc

Thanks for reporting this issue! It looks like an issue with the resource loader module, not the LWC framework (this repo). To resolve your issue, I would recommend opening a Salesforce Stack Exchange question or a Salesforce case.

wjhsf avatar Jan 10 '25 17:01 wjhsf

Thank you @wjhsf I've created a question here https://salesforce.stackexchange.com/questions/429373/async-await-syntax-is-broken-in-static-resource-on-firefox

sinhgc avatar Jan 13 '25 08:01 sinhgc