Chat SDK v4 send message onSucceeded handler not called

Both sendUserMessage.onSucceeded and sendFileMessage.onSucceeded handlers are not called after sending a user/file message, even after MessageCollectionHandler.onMessageUpdated received the event EVENT_MESSAGE_SENT_SUCCESS for that particular message.

I am having a similar issue. Is there a reason that sendUserMessage doesn’t just return a promise? Neither the onSucceeded nor the onFailed callbacks are being executed for me. But I do see that the thunk is dispatching a rejected action in my redux store…

return new Promise((resolve, reject) => {
      .sendUserMessage({ message: text })
      .onSucceeded(message => {
        console.log({ message })
        resolve({ channelUrl: url, message: message as Message })
      .onFailed(error => {
        console.log({ error })
        logError('Unable to send message', { url: channel.url, error })
1 Like

Hi @jkepps,

Let me dig into this. From what I can tell looking at the code, .onSucceeded and .onFailed should definitely be called.

@Tyler any updates on this?

managed to figure out the mistake i was making. since i store the channels in redux, i have to serialize them, and i was forgetting to rebuild the channel with the serialized object before calling sendUserMessage on the channel :man_facepalming:

Would still love some insight into the design decision around sendUserMessage not returning a promise, if possible.

Hey @jkepps,

Apologies for the lack of follow up on this. It’s been a bit of a crazy week for me. The reason sendUserMessage does not return a promise is because it returns twice. It first returns the pending message and then returns the onFailed or onSuccess. Unfortunately, Promises do not support this and thus the need to build the handler.