# fetchWidgetData script goes into a loop and spams with requests

**URL:** <https://community.hubspot.com/t/fetchwidgetdata-script-goes-into-a-loop-and-spams-with-requests/104720>\
**Category:** APIs & Integrations\
**Tags:** developer-tools, timeline-and-extensions-apis\
**Created:** [April 12, 2024, 2:52pm UTC](https://community.hubspot.com/t/fetchwidgetdata-script-goes-into-a-loop-and-spams-with-requests/104720 "2024-04-12T14:52:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ASchadnev](https://avatars.discourse-cdn.com/v4/letter/a/838e76/32.png) [@ASchadnev](https://community.hubspot.com/u/ASchadnev)\
**Post date:** [April 12, 2024, 2:52pm UTC](https://community.hubspot.com/t/fetchwidgetdata-script-goes-into-a-loop-and-spams-with-requests/104720/1 "2024-04-12T14:52:43Z")

</div>

script launch with transfer of user authorization data is implemented.

The problem occurs when the widget is connected with a specific user (token + mail) and the page reloads. At that point, requests start pouring in until the stack is full. After that the widget is reloaded and everything is normal.

When reloading, two methods are called to clear the chat after user change:

window.HubSpotConversations.clear({ resetWidget: true });  
window.HubSpotConversations.widget.load();

 ![Screenshot 2024-04-12 162806.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/4/48df5530076e6c8ef1346d674bf331e8e21d8d3e.png)

 ![Screenshot 2024-04-12 162737.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/3/d/3df79dbcaa6dfccdf10a62e567b90a215969bbbc.png)

---

<div class="post-metadata">

**Author:** ![HMir](https://avatars.discourse-cdn.com/v4/letter/h/dec6dc/32.png) [@HMir](https://community.hubspot.com/u/HMir)\
**Post date:** [June 8, 2024, 8:43am UTC](https://community.hubspot.com/t/fetchwidgetdata-script-goes-into-a-loop-and-spams-with-requests/104720/2 "2024-06-08T08:43:03Z")

</div>

> * * *
> 
> @ASchadnev wrote:
> 
> script launch with transfer of user authorization data is implemented.
> 
> The problem occurs when the widget is connected with a specific user (token + mail) and the page reloads. At that point, requests start pouring in until the stack is full. After that the widget is reloaded and everything is normal.
> 
> When reloading, two methods are called to clear the chat after user change:
> 
> window.HubSpotConversations.clear({ resetWidget: true });  
> window.HubSpotConversations.widget.load();

 ![Screenshot 2024-04-12 162806.png](https://d2qpr2jzcazej7.cloudfront.net/original/2X/4/48df5530076e6c8ef1346d674bf331e8e21d8d3e.png)

 ![Screenshot 2024-04-12 162737.png](https://d2qpr2jzcazej7.cloudfront.net/original/3X/3/d/3df79dbcaa6dfccdf10a62e567b90a215969bbbc.png)

> * * *

To address this problem, two methods are called to clear the chat after a user change:  
window.HubSpotConversations.clear({ resetWidget: true });  
window.HubSpotConversations.widget.load();

These methods aim to reset the widget and clear any existing chat data. However, it appears that they may not be functioning as expected, leading to the continuous loop of requests. To troubleshoot, ensure that these methods are correctly implemented and called at the appropriate times, such as before the widget is reloaded. Additionally, consider checking for any potential conflicts or issues with other scripts or components on the page that could be affecting the behavior of the widget. Debugging and testing these methods thoroughly can help identify and resolve the root cause of the loop and spamming of requests.
