Commit c39d25c
authored
fix(auth): prevent re-entrant logout calls on session expiry (#7779)
# Motivation
When the session expires, `logout()` calls `authStore.signOut()` which
sets identity to `null`. This triggers reactive cascades where in-flight
services call `getAuthenticatedIdentity()`, see the missing identity,
and each independently call `logout()` again. Each call appends
duplicate URL params via `.append()` before the browser reloads, which
can lead to oversized headers (HTTP 431).
Related to:
https://forum.dfinity.org/t/proposal-140767-to-upgrade-the-nns-dapp-2026-03-06/65145/4?u=yhabib
# Changes
- Added a `logoutInProgress` re-entrancy guard to `logout()` so only the
first call proceeds.
- Switched `appendMsgToUrl` from `searchParams.append()` to
`searchParams.set()` to prevent duplicate URL params as a secondary
defense.
# Tests
- Added a test verifying concurrent logout calls only trigger one
`signOut` and one `reload`.
# Todos
- [x] Accessibility (a11y) – any impact?
- [x] Changelog – is it needed?1 parent f6985a7 commit c39d25c
File tree
4 files changed
+34
-2
lines changed- .config
- frontend/src
- lib/services
- tests/lib/services
4 files changed
+34
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
15 | 22 | | |
16 | 23 | | |
17 | 24 | | |
| |||
33 | 40 | | |
34 | 41 | | |
35 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
36 | 51 | | |
37 | 52 | | |
38 | 53 | | |
| |||
95 | 110 | | |
96 | 111 | | |
97 | 112 | | |
98 | | - | |
99 | | - | |
| 113 | + | |
| 114 | + | |
100 | 115 | | |
101 | 116 | | |
102 | 117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
185 | 185 | | |
186 | 186 | | |
187 | 187 | | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
188 | 202 | | |
189 | 203 | | |
190 | 204 | | |
| |||
0 commit comments