mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 03:57:52 +00:00
fix: TypeError Unhandled Promise Rejection: null is not an object (evaluating 'e[Symbol.iterator]') (#10007)
# Pull Request Template ## Description **Cause of Issue** The problem was that the `clearSelectedState` action was being dispatched late in the component lifecycle. By the time it was called, child components like `ConversationBox` and `MessagesView` had already been mounted and were trying to access data from a previous conversation that no longer existed. This resulted in throwing error `TypeError Unhandled Promise Rejection: null is not an object (evaluating 'e[Symbol.iterator]')` when users navigated from other screens to the conversation view screen. **Solution** I added the `clearSelectedState` dispatch to the `created()` lifecycle hook for cases where there's no `conversationId` from route props. This ensures that the state is cleared before any child components are mounted. Fixes https://chatwoot-p3.sentry.io/issues/5707937964/?project=4507182691975168 ## Type of change Please delete options that are not relevant. - [x] Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? **Steps to reproduce** 1. Navigate to chat list screen and open the console. 2. Open any chat, wait to load the messages and stay in conversation view screen. 3. Then navigate to contact or any other view from primary sidebar. 4. Then back to chat list view. 5. Now you can see this error in console. **Before** https://www.loom.com/share/193aaf1d1926479982a192dfb06a8764?sid=3f9ee000-d6a0-47cc-a49f-0050d2c64bbf **After** https://www.loom.com/share/3d88cfd5e7744958bc5856dd601ee6c4?sid=0e07a5d0-e461-4a1a-914b-e49f669422f5 ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [x] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules
This commit is contained in:
@@ -87,6 +87,17 @@ export default {
|
||||
this.fetchConversationIfUnavailable();
|
||||
},
|
||||
},
|
||||
|
||||
created() {
|
||||
// Clear selected state early if no conversation is selected
|
||||
// This prevents child components from accessing stale data
|
||||
// and resolves timing issues during navigation
|
||||
// with conversation view and other screens
|
||||
if (!this.conversationId) {
|
||||
this.$store.dispatch('clearSelectedState');
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.$store.dispatch('agents/get');
|
||||
this.initialize();
|
||||
|
||||
Reference in New Issue
Block a user