3.1.2 Admin msg causing error

Hi,
I’m using latest “sendbird-uikit”: “2.5.0” for React.
And I believe sendbird-uikit is using SendBird-SDK-JavaScript v.3.1.2

When sending ‘Admin message’ - chat is causing error:

TypeError: Cannot read properties of undefined (reading ‘userId’)

It’s line number 7389:
var r = n.memberMap[this._sender.userId];

I’ve checked with SendBird-SDK-JavaScript v.3.0.160 - and everything was fine. Looks like some recent changes in library - are causing this new error. Screenshots attached.

1 Like

We are having the exact same error, and nothing has worked. This has become a huge blocker.

Hi @cole and @developer,

Can you both confirm which version of the Sendbird SDK is installed by looking at the package-lock.json?

I’ll happily take a look at what is going on.

The broken version is SendBird-SDK-JavaScript v.3.1.2, which is the latest. It works when manually installed SendBird-SDK-JavaScript v.3.0.160.

Hi @Tyler
In my package.json I have:

"sendbird-uikit": "2.5.0",

My package-lock.json includes:


    "sendbird": {
      "version": "3.1.2",
      "resolved": "https://registry.npmjs.org/sendbird/-/sendbird-3.1.2.tgz",
      "integrity": "sha512-vwrbS0ublFgyvJLl0qUTevH/03VYH/0/c1qG8xHB0ofYvdF0ozqZESL0SM8LGkhVo5neogi2zb07+kd2uuaCJw==",
      "requires": {
        "agentkeepalive": "4.1.4",
        "axios": "^0.21.4",
        "form-data": "^4.0.0",
        "ws": "^7.5.5"
      },
      "dependencies": {
        "form-data": {
          "version": "4.0.0",
          "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz",
          "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==",
          "requires": {
            "asynckit": "^0.4.0",
            "combined-stream": "^1.0.8",
            "mime-types": "^2.1.12"
          }
        },
        "ws": {
          "version": "7.5.6",
          "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.6.tgz",
          "integrity": "sha512-6GLgCqo2cy2A2rjCNFlxQS6ZljG/coZfZXclldI8FB/1G3CCI36Zd8xy2HrFVACi8tfk5XrgLQEk+P0Tnz9UcA==",
          "requires": {}
        }
      }
    },
    "sendbird-uikit": {
      "version": "2.5.0",
      "resolved": "https://registry.npmjs.org/sendbird-uikit/-/sendbird-uikit-2.5.0.tgz",
      "integrity": "sha512-P7knRFX/XuoZY2EWX5iZLIz/y5PyWtAD0ksoS8Xr8Va1hJhD5EIF8GR99fmuspUDFlxj6sJ8fCu25RDNYIxzgA==",
      "requires": {
        "css-vars-ponyfill": "^2.3.2",
        "date-fns": "^2.16.1",
        "prop-types": "^15.7.2",
        "react": "^16.8.6 || ^17.0.0",
        "react-dom": "^16.8.6 || ^17.0.0",
        "sendbird": "^3.0.160"
      }
    },

Also attached screenshot - where the error + SDK version is visible in file comment.

We’re seeing this as well on 3.1.0 and above. Any channel with Admin messages will trigger a fatal error and break the page

export const isSameGroup = (message, comparingMessage) => {
  if (
    !message
    || !comparingMessage
    || !message.sender
    || !comparingMessage.sender
    || !message.createdAt
    || !comparingMessage.createdAt
    || !message.sender.userId
    || !comparingMessage.sender.userId
  ) {
    return false;
  }
  return (
    message.sendingStatus === comparingMessage.sendingStatus
    && message.sender.userId === comparingMessage.sender.userId
    && getMessageCreatedAt(message) === getMessageCreatedAt(comparingMessage)
  );
};

isSameGroup is assuming all messages have a sender attribute. This is not true for AdminMessages as seen in the type definitions. Is Sendbird not using its own type definitions for static validation?

interface AdminMessage extends BaseMessageInstance {
  messageType: 'admin';
  message: string;
  translations: Object;
}

interface UserMessage extends BaseMessageInstance {
  messageType: 'user';
  message: string;
  sender: Sender;
  reqId: string;
  ...
}


FYI this is still an issue with 3.1.3:

ETA for fix is EoD of 12/14 KST.

The fix was released in JS SDK 3.1.4 and UIKit 2.5.1

1 Like