Getting weird 400 error on /polls without actually using or requesting it

[Problem/Question]
Since I started introducing the channel and message collections as outlined in the chapter on Local Caching I’m getting four GET errors in my console. They seem to be coming from (for lack of a better word “deep within” the package and I cant figure out what causes them or how to get rid of them. The closest I’ve gotten is that it seems to be originating from the messageCollection and not from the channelCollection, but I might as well be wrong.

GET https://api-21e39857-6e26-43aa-9444-c4dad039fb1e.sendbird.com/v3/group_channels/sendbird_group_channel_209147624_4faf4b8657a5fac4f3f2694f3a4e5970de6d20e0/polls/changelogs?change_ts=1667284665722 400

What quizzes me most is the /polls because I don’t even use polls at all nor do I intend to.


// If problem, please fill out the below. If question, please delete.
[SDK Version]
@sendbird/chat": “^4.1.1”,
“vue”: “^3.2.41”,
“typescript”: “^4.8.4”,

[Reproduction Steps]

  const sb = await getSendbirdClient();

  const channel = await getChannel(sb, channelUrl);

  const state = reactive({
    messages: [] as BaseMessage[],
    collection: null as unknown,
  });

  const onCacheResult = (err: Error, messages: BaseMessage[]) => {
    // Messages are retrieved from the local cache.
    // They might be too outdated or far from the startingPoint.
    state.messages = messages;
    console.log("onCacheResult MSG", messages);
  };
  const onApiResult = (err: Error, messages: BaseMessage[]) => {
    // Messages are retrieved from the Sendbird server through API.
    // According to MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API,
    // the existing data source needs to be cleared
    // before adding retrieved messages to the local cache.
    state.messages = messages;
    console.log("onApiResult MSG", messages);
  };

  const messageHandlers: MessageCollectionEventHandler = {
    onMessagesAdded: (
      context: MessageEventContext,
      channel: GroupChannel,
      messages: BaseMessage[]
    ) => {
      // Add the messages to your data source.
      console.log("MESSAGE ADDED", messages);
      state.messages = [...state.messages, ...messages];
    },
    onMessagesUpdated: (
      context: MessageEventContext,
      channel: GroupChannel,
      messages: BaseMessage[]
    ) => {
      // Update the messages in your data source.
      const updatedMessages = [...state.messages];
      for (const i in messages) {
        const incomingMessage = messages[i];
        const indexOfExisting = state.messages.findIndex((message) => {
          return incomingMessage.messageId === message.messageId;
        });

        if (indexOfExisting !== -1) {
          updatedMessages[indexOfExisting] = incomingMessage;
        }
        if (!incomingMessage.messageId) {
          updatedMessages.push(incomingMessage);
        }
      }
      state.messages = updatedMessages;
    },
    onMessagesDeleted: (
      context: MessageEventContext,
      channel: GroupChannel,
      messageIds: number[]
    ) => {
      // Remove the messages from the data source.
      const updatedMessages = state.messages.filter((message) => {
        return !messageIds.includes(message.messageId);
      });
      state.messages = updatedMessages;
    },
    onChannelUpdated: (
      context: GroupChannelEventContext,
      channel: GroupChannel
    ) => {
      // Change the chat view with the updated channel information.
      console.log("MESSAGE HANDLER, GroupChannel updated");
    },
    onChannelDeleted: (
      context: GroupChannelEventContext,
      channelUrl: string
    ) => {
      // This is called when a channel was deleted. So the current chat view should be cleared.
      console.log("MESSAGE HANDLER, GroupChannel deleted");
    },
    onHugeGapDetected: () => {
      // The Chat SDK detects more than 300 messages missing.
      console.log("HUGE GAP DETECTED");
      // collection.dispose();
    },
  };

  const filter: MessageFilter = new MessageFilter();
  const limit = 100;
  const startingPoint: number = Date.now();
  const collection: MessageCollection = channel.createMessageCollection({
    filter,
    limit,
    startingPoint,
  });
  collection.setMessageCollectionHandler(messageHandlers);

  collection
    .initialize(MessageCollectionInitPolicy.CACHE_AND_REPLACE_BY_API)
    .onApiResult(onApiResult)
    .onCacheResult(onCacheResult);

  if (collection.hasPrevious) {
    // Load the previous messages when the scroll
    // reaches the first message in the chat view.
    const messages: BaseMessage[] = await collection.loadPrevious();
    state.messages = [...messages, ...state.messages];
  }

  if (collection.hasNext) {
    // Load the next messages when the scroll
    // reaches the last message in the chat view.
    const messages: BaseMessage[] = await collection.loadNext();
    state.messages = [...state.messages, ...messages];
  }

  state.collection = collection;

1 Like