Commit 71a9260
committed
refactor: replace _authRetryInFlight class field with isAuthRetry parameter
Stops the 10-comment whack-a-mole around flag lifecycle. A mutable
boolean class field is the wrong primitive for 'retry once per
operation' when operations are concurrent and recursive — every
reset point creates a race, every missed reset creates a stuck flag.
Now all four 401 paths use parameter-passed isAuthRetry:
- StreamableHTTP _startOrAuthSse(options, isAuthRetry = false):
recursion passes true. No class field, no reset sites.
- StreamableHTTP send() delegates to private _send(message, options,
isAuthRetry). Recursion passes true. No class field.
- SSE _startOrAuth(isAuthRetry = false): onerror callback captures
isAuthRetry from closure; retry calls _startOrAuth(true).
- SSE send() delegates to private _send(message, isAuthRetry).
Per-operation state dies with the stack frame. Concurrent operations
cannot observe each other's retry state. 12 reset sites deleted.
Also makes SSE onerror fallback consistent with other paths — throws
SdkError(ClientHttpAuthentication) for the circuit-breaker case
instead of plain UnauthorizedError.
Not addressed (noted for auth() cleanup): concurrent 401s still each
call onUnauthorized() independently. Deduplicating that (in-flight
promise pattern) would be a behavior change.1 parent b31d8d9 commit 71a9260
2 files changed
+31
-34
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
102 | 101 | | |
103 | 102 | | |
104 | 103 | | |
| |||
119 | 118 | | |
120 | 119 | | |
121 | 120 | | |
122 | | - | |
| 121 | + | |
123 | 122 | | |
124 | 123 | | |
125 | 124 | | |
| |||
148 | 147 | | |
149 | 148 | | |
150 | 149 | | |
151 | | - | |
152 | | - | |
| 150 | + | |
153 | 151 | | |
154 | 152 | | |
155 | 153 | | |
156 | | - | |
| 154 | + | |
157 | 155 | | |
158 | 156 | | |
159 | 157 | | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | 158 | | |
164 | 159 | | |
165 | 160 | | |
166 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
167 | 166 | | |
168 | 167 | | |
169 | 168 | | |
| |||
247 | 246 | | |
248 | 247 | | |
249 | 248 | | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
250 | 253 | | |
251 | 254 | | |
252 | 255 | | |
| |||
271 | 274 | | |
272 | 275 | | |
273 | 276 | | |
274 | | - | |
275 | | - | |
| 277 | + | |
276 | 278 | | |
277 | 279 | | |
278 | 280 | | |
279 | 281 | | |
280 | 282 | | |
281 | 283 | | |
282 | 284 | | |
283 | | - | |
| 285 | + | |
284 | 286 | | |
285 | 287 | | |
286 | | - | |
| 288 | + | |
287 | 289 | | |
288 | 290 | | |
289 | 291 | | |
| |||
295 | 297 | | |
296 | 298 | | |
297 | 299 | | |
298 | | - | |
299 | | - | |
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
303 | | - | |
304 | 303 | | |
305 | 304 | | |
306 | 305 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
152 | | - | |
153 | 151 | | |
154 | 152 | | |
155 | 153 | | |
| |||
198 | 196 | | |
199 | 197 | | |
200 | 198 | | |
201 | | - | |
| 199 | + | |
202 | 200 | | |
203 | 201 | | |
204 | 202 | | |
| |||
227 | 225 | | |
228 | 226 | | |
229 | 227 | | |
230 | | - | |
231 | | - | |
| 228 | + | |
232 | 229 | | |
233 | 230 | | |
234 | 231 | | |
235 | 232 | | |
236 | 233 | | |
237 | 234 | | |
238 | 235 | | |
239 | | - | |
| 236 | + | |
240 | 237 | | |
241 | 238 | | |
242 | | - | |
| 239 | + | |
243 | 240 | | |
244 | 241 | | |
245 | 242 | | |
| |||
252 | 249 | | |
253 | 250 | | |
254 | 251 | | |
255 | | - | |
256 | 252 | | |
257 | 253 | | |
258 | 254 | | |
| |||
262 | 258 | | |
263 | 259 | | |
264 | 260 | | |
265 | | - | |
266 | 261 | | |
267 | 262 | | |
268 | | - | |
269 | 263 | | |
270 | 264 | | |
271 | 265 | | |
| |||
475 | 469 | | |
476 | 470 | | |
477 | 471 | | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
478 | 480 | | |
479 | 481 | | |
480 | 482 | | |
| |||
516 | 518 | | |
517 | 519 | | |
518 | 520 | | |
519 | | - | |
520 | | - | |
| 521 | + | |
521 | 522 | | |
522 | 523 | | |
523 | 524 | | |
524 | 525 | | |
525 | 526 | | |
526 | 527 | | |
527 | 528 | | |
528 | | - | |
| 529 | + | |
529 | 530 | | |
530 | 531 | | |
531 | | - | |
| 532 | + | |
532 | 533 | | |
533 | 534 | | |
534 | 535 | | |
| |||
573 | 574 | | |
574 | 575 | | |
575 | 576 | | |
576 | | - | |
| 577 | + | |
577 | 578 | | |
578 | 579 | | |
579 | 580 | | |
| |||
583 | 584 | | |
584 | 585 | | |
585 | 586 | | |
586 | | - | |
587 | | - | |
588 | 587 | | |
589 | 588 | | |
590 | 589 | | |
| |||
634 | 633 | | |
635 | 634 | | |
636 | 635 | | |
637 | | - | |
638 | 636 | | |
639 | 637 | | |
640 | 638 | | |
| |||
0 commit comments