# Group channel creation does work anymore after user creation

**URL:** <https://community.sendbird.com/t/group-channel-creation-does-work-anymore-after-user-creation/10140>\
**Category:** API\
**Tags:** group-channel\
**Created:** [October 2, 2024, 12:23am UTC](https://community.sendbird.com/t/group-channel-creation-does-work-anymore-after-user-creation/10140 "2024-10-02T00:23:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![System\_Yumi](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/system_yumi/32/5140_2.png) [@System\_Yumi](https://community.sendbird.com/u/System_Yumi)\
**Post date:** [October 2, 2024, 12:23am UTC](https://community.sendbird.com/t/group-channel-creation-does-work-anymore-after-user-creation/10140/1 "2024-10-02T00:23:51Z")

</div>

**[Problem/Question]**  
Creation of GroupChannel doesn’t work anymore just after user creation.

**[Reproduction Steps]**  
Create a user  
Create a group channel between this user and an other user  
Group channel has only one member

**[Frequency]**  
This is a new bug since few weeks, maybe months.

**[Current impact]**  
This is impacting my production app

---

<div class="post-metadata">

**Author:** ![Chinmaya\_Gupta](https://sea2.discourse-cdn.com/flex020/user_avatar/community.sendbird.com/chinmaya_gupta/32/1021_2.png) [@Chinmaya\_Gupta](https://community.sendbird.com/u/Chinmaya_Gupta)\
**Post date:** [October 18, 2024, 11:00am UTC](https://community.sendbird.com/t/group-channel-creation-does-work-anymore-after-user-creation/10140/2 "2024-10-18T11:00:20Z")

</div>

Hi @System_Yumi

Can you please share more details on how are you creating the group channels and what is the error you are receiving so that I can take a look and assist you accordingly?

---

<div class="post-metadata">

**Author:** ![joel](https://avatars.discourse-cdn.com/v4/letter/j/b9bd4f/32.png) [@joel](https://community.sendbird.com/u/joel)\
**Post date:** [November 9, 2024, 2:42pm UTC](https://community.sendbird.com/t/group-channel-creation-does-work-anymore-after-user-creation/10140/3 "2024-11-09T14:42:41Z")

</div>

Hi Chinmaya,

I am having the same or similar problems using the JavaScript SDK in a React app. The two issues are, when I try to create a new channel, the requestedUrl is different than the receivedUrl, and I’m also seeing the same as System\_Yumi, the members array returned by SendBird for new and existing channels only ever has one member. Below is my code and the channelParams I’m sending, along with the response from the SDK. Any assistance would be greatly appreciated.

const handleCreateChat = async () =\> {  
if (selectedContacts.length !== 1 || !user) {  
console.error(‘Cannot create chat: exactly one contact must be selected’);  
return;  
}

```
    try {
        const selectedContact = selectedContacts[0];
        console.log('Creating 1-on-1 chat with contact:', selectedContact);

        // Create channel URL using both user IDs
        const userIds = [user.chatUserId, selectedContact.userId];
        console.log('User IDs:', userIds);
        const channelUrl = `chat_${userIds.join('_')}`;

        console.log('Attempting to create/get channel with URL:', channelUrl);

        let groupChannel;
        try {
            groupChannel = await sb.current.groupChannel.getChannel(channelUrl);
            console.log('Found existing channel:', groupChannel);
        } catch (error) {
            console.log('Error retrieving channel, attempting to create a new one:', error);
            // Create channel params specifically for 1-on-1 chat
            const channelParams: GroupChannelCreateParams = {
                invitedUserIds: userIds,
                name: selectedContact.nickname,
                channelUrl: channelUrl,
                isDistinct: true,
                customType: 'one_to_one'
            };

            console.log('Channel params before creation:', {
                channelParams
            });
            groupChannel = await sb.current.groupChannel.createChannel(channelParams);
            console.log('SendBird response details:', {
                requestedUrl: channelParams.channelUrl,
                receivedUrl: groupChannel.url,
                isDistinct: groupChannel.isDistinct,
                customType: groupChannel.customType,
                members: groupChannel.members.map((m: Member) => m.userId),
                invitedUsers: groupChannel.invitedUsers
            });
            console.log('New channel created:', groupChannel);
        }

        // Verify the channel exists
        if (!groupChannel) {
            throw new Error('Failed to create or get channel');
        }

        // Create conversation object
        const newConversation: ActiveConversation = {
            channelUrl: groupChannel.url,
            name: selectedContact.nickname,
            members: [{
                userId: selectedContact.userId,
                nickname: selectedContact.nickname,
                profileUrl: selectedContact.profileUrl || '/unverified.png'
            }],
            lastMessage: groupChannel.lastMessage?.message || '',
            timestamp: groupChannel.lastMessage?.createdAt || groupChannel.createdAt,
            unreadMessageCount: groupChannel.unreadMessageCount,
            profileUrl: selectedContact.profileUrl || '/unverified.png',
            otherUser: selectedContact,
            customType: 'one_to_one'
        };

        console.log('Created conversation object:', newConversation);

        // Update state using a callback to ensure we have the latest state
        setActiveConversations(prevConversations => {
            console.log('Previous conversations:', prevConversations);

            // Check if conversation already exists
            const existingIndex = prevConversations.findIndex(
                conv => conv.channelUrl === groupChannel.url
            );

            if (existingIndex !== -1) {
                console.log('Conversation exists at index:', existingIndex);
                // If it exists, update it
                const updatedConversations = [...prevConversations];
                updatedConversations[existingIndex] = newConversation;
                console.log('Updated conversations:', updatedConversations);
                return updatedConversations;
            } else {
                // If it doesn't exist, add it to the beginning
                console.log('Adding new conversation');
                const updatedConversations = [newConversation, ...prevConversations];
                console.log('Updated conversations:', updatedConversations);
                return updatedConversations;
            }
        });

        // Close the modal
        handleCloseModal();

        console.log('About to refresh channels, confirmed channel URL:', groupChannel.url);

        // Force a refresh of the channels list
        await fetchUserChannels();

        // Select the new channel
        console.log('Selecting new channel:', groupChannel.url);
        await handleChannelSelect(groupChannel.url);

    } catch (error) {
        console.error('Error in handleCreateChat:', error);
        if (error instanceof Error) {
            console.error('Error details:', {
                message: error.message,
                stack: error.stack,
                name: error.name
            });
        }
    }
};

```

{  
“channelParams”: {  
“invitedUserIds”: [  
“51bb9c1b-51b6-4a73-92e2-f760c8671206”,  
“c7fdd974-2068-4337-a7c6-0d75ee825984”  
],  
“name”: “Mike Hudson”,  
“channelUrl”: “chat\_51bb9c1b-51b6-4a73-92e2-f760c8671206\_c7fdd974-2068-4337-a7c6-0d75ee825984”,  
“isDistinct”: true,  
“customType”: “one\_to\_one”  
}  
}

{  
“requestedUrl”: “chat\_51bb9c1b-51b6-4a73-92e2-f760c8671206\_c7fdd974-2068-4337-a7c6-0d75ee825984”,  
“receivedUrl”: “chat\_51bb9c1b-51b6-4a73-92e2-f760c8671206\_84a12040-8e79-4e8d-b38f-3e3176b7644b”,  
“isDistinct”: true,  
“customType”: “one\_to\_one”,  
“members”: [  
“51bb9c1b-51b6-4a73-92e2-f760c8671206”  
]  
}
