fix(socket): set environ when restoring websocket session #2689
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.