jitsi / jitsi-meet-react-sdk

React SDK for Jitsi Meet
Apache License 2.0
67 stars 39 forks source link

Script loading error persists on retry connection attempt #45

Open anejmarusic opened 5 months ago

anejmarusic commented 5 months ago

I have a React application that integrates your SDK. I'm encountering an issue when attempting a second connection after failing to connect to the Jitsi server initially (likely due to the server being inaccessible). To retry, I'm using a 'Try again' button to reload the JitsiMeeting component. However, on the second attempt, the GET request doesn't even proceed, and the Jitsi React SDK automatically returns the previous error response ('Script load error: https://my.domain.com/external_api.js').

Upon inspecting the source code, I identified that the issue lies within init.js:

let scriptPromise;

export const fetchExternalApi = (domain = DEFAULT_DOMAIN, release, appId) => {
    if (scriptPromise) {
        return scriptPromise;
    }

    scriptPromise = loadExternalApi(domain, release, appId);
    return scriptPromise;
};

It seems that the scriptPromise is saved and reused whenever fetchExternalApi is called again.

Could you please explain the reasoning behind this behavior and suggest a solution for my issue?