Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extraheaders within the socket connection not being updated. #1507

Open
deepakjyadav01 opened this issue Nov 8, 2024 · 0 comments
Open

Extraheaders within the socket connection not being updated. #1507

deepakjyadav01 opened this issue Nov 8, 2024 · 0 comments
Labels
bug Something isn't working frontend Pertains to the frontend. needs-triage

Comments

@deepakjyadav01
Copy link

deepakjyadav01 commented Nov 8, 2024

Describe the bug
I'm using a custom frontend repo and chainlit/react-client lib to establish a WebSocket connection with Chainlit. The issue is that the X-Chainlit-Thread-Id header doesn’t update as expected when I try to set a old thread ID dynamically through idToResume. The header only updates correctly if the page is refreshed. Without a refresh, the header retains an old value or fails to set the new thread ID, resulting in a new connection without the intended idToResume value in the header.

According to my understanding :
IdToResume hook sets the X-Chainlit-Thread-Id header and setIdtoResume from chatInteract can be used to set IdToResume.
Accordinglt whenever IdToResume changes sessionstate recoil state(if you are using one) should get updated right? but it only happens when i reload/refresh the page.

To Reproduce
Steps to reproduce the behavior:

  1. Open the custom frontend and initiate a WebSocket connection with a specific idToResume set in the headers.
  2. Click on an item or perform an action that updates idToResume and should trigger a new WebSocket connection with the updated X-Chainlit-Thread-Id.
  3. Observe that the header does not update as expected and either has an empty X-Chainlit-Thread-Id or retains the old value.
  4. Refresh the page and note that the header is then correctly updated with the intended idToResume.
  5. Expected behavior
  6. The X-Chainlit-Thread-Id header should update dynamically whenever idToResume is changed, without requiring a page refresh to set the new thread ID properly in the WebSocket connection.

I am looking for guidance on the best way to dynamically set X-Chainlit-Thread-Id without refreshing the page each time idToResume is updated. Is there a recommended way to ensure the WebSocket connection uses the updated idToResume header immediately upon reconnecting?
I tried using clear() and disconnect but still facing difficulties in trying to get the header updated when reconnecting to the old chat using Idtoresume hook, though the same functionality works when i reload the page.

@dosubot dosubot bot added bug Something isn't working frontend Pertains to the frontend. labels Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working frontend Pertains to the frontend. needs-triage
Projects
None yet
Development

No branches or pull requests

1 participant