fix(socket): set environ when restoring websocket session#2689
Merged
hayescode merged 3 commits intoChainlit:mainfrom Dec 4, 2025
Merged
Conversation
Contributor
|
@daniel-oronsi thanks for the contribution! I don't see why we would include the environ so looks good to me but please address the CI issues then we can merge this |
Contributor
Author
|
Hey, thanks for the quick response :) I see that |
hayescode
approved these changes
Dec 4, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi,
I encountered this behavior when using
cl.context.session.environto get the HTTP headers.It seemed like the headers were outdated when I used them - and after going through the
connectfunction it seemed likeenvironis not passed to therestore_existing_sessionfunction, which means that the updated socket won't necessarily have the updated environment variables.If there's an intentional reason for this behavior that I'm missing, I'd appreciate some context :)
And one more question - I didn't dive deeply into the authentication flow, but do you think I should also update the user when restoring the session? for now I left it unchanged.
Thanks for the help!
Summary by cubic
Restored websocket sessions now receive the current request environ so headers and context stay up to date after reconnects. This prevents stale header usage in session logic.
Written for commit 0b840fe. Summary will update automatically on new commits.