Commit 71a8e8f
fix(socket): set environ when restoring websocket session (#2689)
Hi,
I encountered this behavior when using `cl.context.session.environ` to
get the HTTP headers.
It seemed like the headers were outdated when I used them - and after
going through the `connect` function it seemed like `environ` is not
passed to the `restore_existing_session` function, 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!
<!-- This is an auto-generated description by cubic. -->
---
## 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.
- **Bug Fixes**
- Added an environ parameter to restore_existing_session and set
session.environ during restore.
- Passed environ when restoring a session and updated tests to assert
environ propagation and not-found behavior.
<sup>Written for commit 0b840fe.
Summary will update automatically on new commits.</sup>
<!-- End of auto-generated description by cubic. -->
---------
Co-authored-by: Josh Hayes <[email protected]>1 parent 85a4f87 commit 71a8e8f
File tree
3 files changed
+14
-10
lines changed- backend
- chainlit
- tests
- cypress/e2e/header_auth
3 files changed
+14
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
149 | 150 | | |
150 | 151 | | |
151 | 152 | | |
152 | | - | |
| 153 | + | |
153 | 154 | | |
154 | 155 | | |
155 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| 121 | + | |
121 | 122 | | |
122 | 123 | | |
123 | 124 | | |
124 | 125 | | |
125 | 126 | | |
126 | | - | |
| 127 | + | |
127 | 128 | | |
128 | 129 | | |
129 | 130 | | |
130 | 131 | | |
131 | 132 | | |
132 | 133 | | |
| 134 | + | |
133 | 135 | | |
134 | 136 | | |
135 | 137 | | |
136 | 138 | | |
137 | 139 | | |
138 | 140 | | |
139 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
140 | 144 | | |
141 | 145 | | |
142 | 146 | | |
| |||
407 | 411 | | |
408 | 412 | | |
409 | 413 | | |
410 | | - | |
| 414 | + | |
411 | 415 | | |
412 | 416 | | |
413 | 417 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | 18 | | |
24 | 19 | | |
25 | 20 | | |
| |||
55 | 50 | | |
56 | 51 | | |
57 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
58 | 57 | | |
59 | 58 | | |
60 | 59 | | |
| |||
0 commit comments