Skip to content

Conversation

@vinhnxv
Copy link

@vinhnxv vinhnxv commented Feb 3, 2026

Summary

  • Move session creation before extractSDKMetadataAsync callback
  • Reuse existing session instance instead of creating new one inside callback

Problem

The session sync client was being created inside the extractSDKMetadataAsync callback:

extractSDKMetadataAsync(async (sdkMetadata) => {
    api.sessionSyncClient(response).updateMetadata(...) // Creates new client each time
});

const session = api.sessionSyncClient(response); // Another instance created here

This could lead to race conditions with multiple session client instances.

Solution

Create the session client once, before the async metadata extraction:

const session = api.sessionSyncClient(response); // Create FIRST

extractSDKMetadataAsync(async (sdkMetadata) => {
    session.updateMetadata(...) // Reuse existing instance
});

Test Plan

  • Verify session metadata updates correctly
  • Check no duplicate session clients are created

Prevents race condition where multiple session client instances
could be created inside the extractSDKMetadataAsync callback.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant