Skip to content

Intermittent "Script is not loaded" Error when using callbackName #6

Closed
@mikehazell

Description

@mikehazell

Hey there,

We're getting this error intermittently when trying to load the GoogleMaps Api.

It looks like what's happening is that asyncScriptLoaderTriggerOnScriptLoaded is being called before the script onLoad event fires. Only happens about once in 5 refreshes.

I have a workaround that feels kind of hacky. It just ignores mapEntry.loaded if callbackName is defined.

      asyncScriptLoaderTriggerOnScriptLoaded() {
        let mapEntry = SCRIPT_MAP.get(scriptURL);
        const { callbackName } = options;
        if (!mapEntry || !mapEntry.loaded && !callbackName) {
          throw new Error("Script is not loaded.");
        }

I'd be happy to help out with this. Not sure what the right direction to go is though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions