Auth0 Home Blog Docs

Auth0-spa-js - failed call to createAuth0Client takes a minute to return


I am using auth0-spa-js with React. I have created an Auth0Provider as per the documentation, and when I have an internet connection everything works fine.

However I have noticed that if I don’t have an internet connection, the call to await createAuth0Client(…) takes about a minute to return, even though the network call fails immediately.

For example the network call to https://[my-custom-auth-domain]/authorize?.. fails immediately with ERR_NAME_NOT_RESOLVED. I would expect in this case for the call to return immediately so my IsLoading state can be set to false and I can show an appropriate screen on my app. But because of this delay, on startup my app stays on the loading screen for a minute which is not acceptable.

I am passing the below configuration to createAuth0Client:

audience: ‘[my audience value]’,
client_id: ‘[my client id]’,
domain: ‘[my custom auth domain]’,
redirect_uri: window.location.origin,

Is there as way I can resolve this by perhaps passing a timeout value, or does this require a change in the library? Thanks.