App.initialized() is not working

Hi @Raviraj

I’m building a custom app, and in that app, sometimes the app.initialized() was not working. My code was not executed after app.initialized(), and I am not able to get the client object.I didn’t get the errors from that line.

client initialization

document.onreadystatechange = async function () {
  if (document.readyState === "interactive") renderApp();
};
async function renderApp() {
  console.log("yess");
  try {
    console.log("Try");
    let _client = await app.initialized();

    console.log(_client);
   
      
  } catch (err) {
    console.log("catch");
    errorHandler(err, "Something went wrong. Please contact administrator");
  }
}

If client was not initialized

if initialized

any inputs please @Raviraj @zach_jones_noel

Hi @Kithiyon,

Do you see any pattern on when does the client not load?
Could you add a try-catch block and check it if there’s any error in the catch block?

Could you share how the appclient is imported in the respective HTML file?

Thanks for the inputs @Raviraj

I didn’t see anything about failed client loading.

I already added the try-catch block; you can see that code on the first command. If I should add more try-catch blocks, can you tell me where I should add them?

@Raviraj

Can you help me resolve this issue ASAP? Our client urgently needs this app.

Thanks,

Hi @Kithiyon,

I couldn’t reproduce the issue using the same code on Freshdesk. Anyway, I have created a support ticket to troubleshoot this issue further by the team and respond back to you.
Please reply in the respective email thread for this ticket for further communication. Thanks.

Thanks @Raviraj

I’m not able to reproduce the same issue while testing on local

Sure, I will check it as a custom app as well.

Could you add defer keyword to the app.js import script and check if it works more reliably now?

<script defer src="scripts/app.js"></script>

I couldn’t reproduce it as a custom app as well with the defer keyword added.

If I use ‘defer,’ I don’t get the client while using the local and custom apps either. If possible, can we connect?

Hi @Kithiyon,

I have created a support ticket on your behalf here - #15832266
Could you please respond to them via email with the required details to troubleshoot further?

Hi @Kithiyon @Raviraj

I’m also facing the same issue. The client-side app fails often now and since my app uses a modal that opens. That also seems to be failing randomly.

If you find the issue please do help me as well

Hi @mohammed

The Freshworks Market Place team is debugging the issue. If this issue is resolved, I will update here.

1 Like

Hi @Raviraj and @mohammed

Here is the solution, I have changed my code into

document.onreadystatechange = async function () {
  if (document.readyState === "complete") renderApp();
};

after these changes i’m not able to reproduce the issue.If anyone want to know more about “document.readyState” please refer here.

1 Like