Connection data is not available. Please authenticate first

is this message come from amity? i have an uncaught error with above message, i want to confirm/validate whether the message come from amity

Hello, could you kindly provide the complete error log or a screenshot? Also, could you specify the exact line of code where this error occurs?

"Uncaught (in promise) Error: Connection data is not available. Please authenticate first."

i read this on posthog replay of our prod app, the stack trace comes from minified script. which we cant really debug it.

but we are able to capture this from sentry log

{snip} {if(this._connectionData)return this._connectionData;throw new Error("Connection data is not available. Please authenticate first.")},set:fu {snip}

Are you encountering this error only in the production environment and not in any other environments or locally?

Could you also help provide your current Amity SDK version, please?

i think we only captured this on production and unable to recreate in local.

"@amityco/js-sdk": "^5.31.0",
1 Like

Hello, upon consultation with our team, it appears this error arises if actions are performed before the login process is fully completed. We advise reviewing your login workflow.

Additionally, we recommend transitioning to the TypeScript SDK, which offers enhanced features and improved performance. It’s also worth noting that the JavaScript SDK will be deprecated in September this year. For more information, please refer to the announcement here: Install JavaScript SDK (Deprecated) | Amity Docs.

could you help specify which actions?

All function calls are considered an action, such as entering communities or chats, for example.

For reference, please consult Amity’s SDK documentation on session states. It’s important to ensure that the session state is established before proceeding to call other functions.

im unable to observe session state with

client = new ASCClient({ apiKey, apiEndpoint, apiRegion });
client.on('sessionStateChanged', ({ newValue }) => {
  console.log('session state', newValue);

is it not available in my current version?

package version

"@amityco/js-sdk": "^5.31.0",

Session state is available from version 5.35+, however, we would recommend updating to the latest version or transition to TS SDK.