Repository navigation
Commit e66a3d8
Clear the OAuth popup result from localStorage after handover (#1570)
* Clear the OAuth popup result from localStorage after handing it over
The callback page writes its result to localStorage as the reliable same-origin
completion channel, and the opener removes it on pickup. When nothing is
listening — an abandoned flow, a reloaded opener, any caller not using the React
helper — nobody ever removes it, and the payload carries the identity label (an
email) and, on failure, the error preview. It sat in the user's browser profile
indefinitely.
The page now clears its own entry: on success just before the existing
auto-close, and on failure after a delay, since a failed flow deliberately keeps
the window up. This cannot cost a listener the result — a `storage` event
captures `newValue` at dispatch, so an opener that was notified already holds
it, and the only other reader polls `popup.closed`, not storage.
The tests RUN the generated script against stub globals rather than matching its
source, because a string assertion passes just as well on a script that never
executes, and what is at stake here is what the browser is left holding.
* Add a changeset for the popup storage-residue fix
* fix(api): don't strand the OAuth error payload when the user closes the failure popup
The failure page never auto-closes so the user can read the error, and
its localStorage clear rode solely on a 5s timer. Closing the window
earlier killed the pending timer, and with no opener listening (COOP
severs window.opener; a reloaded app tab has no storage listener)
nothing else removed the key — the error payload sat in the browser
profile forever, exactly the residue this branch exists to eliminate.
A pagehide listener now clears the entry when the document dies; the
timers stay for the page merely sitting open. Clearing on pagehide
cannot cost a listener the result: a storage event captures newValue at
dispatch, and the opener ignores the null-newValue removal event.
---------
Co-authored-by: Rhys Sullivan <39114868+RhysSullivan@users.noreply.github.com>1 parent c8bb857 commit e66a3d8
3 files changed
Lines changed: 121 additions & 1 deletion
File tree
- .changeset
- packages/core/api/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
152 | 252 | | |
153 | 253 | | |
154 | 254 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
122 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
123 | 134 | | |
124 | 135 | | |
125 | 136 | | |
| |||
0 commit comments