microsoft-graph-toolkit
microsoft-graph-toolkit copied to clipboard
[BUG] [MGT-CHAT] Rapid switching between chats can cause messages from the wrong chat to be cached
Describe the bug By switching quickly between chats, it is possible for messages from the wrong chat to be cached and shown.
To Reproduce To reproduce this issue you need to be able to switch quickly between chats. You can use the ChatList component in PR if you want.
Steps to reproduce the behavior:
- Clear all cache in mgt-conversations / chats
- Open a chat but before it finishes loading
- Switch to a different chat and before it finishes loading
- Switch to a different chat
- Observe that the chat contains messages from several of those that were not finished loading. Moreover they are not just displayed, but also in the cache for the wrong chat.
NOTE: this is not 100% reproduceable. I am pretty sure this happens because a graph call is started but not completed under chatID X and then its response is received when the component is chatID Y.
Expected behavior When set to a specific chatID you never see messages from another chatID.
Screenshots
Here is the chat in MGT:
Here is the chat in Teams:
Messages 111 and 112 actually came from this chat:
Notice that in the cache, the key doesn't match the chat ID:
Environment (please complete the following information):
- OS: macOS Monteray 12.7.3
- Browser: edge
- Framework: react
- Context: Web
- Version: we tested version 4, but this probably appeared previously
- Provider: Msal2Provider
Additional context I am a MSFT employee, you can reach me on Teams at pelasne.