fix: DPoP nonce retry race issue#2580
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2580 +/- ##
==========================================
+ Coverage 90.09% 90.18% +0.08%
==========================================
Files 63 63
Lines 7614 7590 -24
Branches 1615 1615
==========================================
- Hits 6860 6845 -15
+ Misses 742 733 -9
Partials 12 12 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
# Conflicts: # src/server/auth-client.ts
3b36da5 to
bd1c457
Compare
|
|
||
| let fetcher: Fetcher<Response>; | ||
| if (this.provider) { | ||
| fetcher = await this.provider.getProxyFetcher(cacheKey, async () => { |
There was a problem hiding this comment.
Removing getProxyFetcher from this file makes getProxyFetcher a dead code, that can be removed.
There was a problem hiding this comment.
auth-client-provider.ts:42: const MAX_PROXY_FETCHERS = 100
auth-client-provider.ts:64: private proxyFetchers: LruMap<string, any>
auth-client-provider.ts:79: this.proxyFetchers = new LruMap(MAX_PROXY_FETCHERS
auth-client-provider.ts:207-220: getProxyFetcher() method
auth-client-provider.test.ts:519-600: Tests for getProxyFetcher
mcd.integration.test.ts:750-780: MCD integration tests for proxy fetcher caching
These are dead code after this change
| // Fetcher-scoped DPoP handle and nonce management | ||
| dpopHandle: | ||
| this.useDPoP && (options.useDPoP ?? true) | ||
| options.dpopHandle ?? |
There was a problem hiding this comment.
Not sure about this implementation even if useDPoP is false and user passes some dpopHandle this will pass.
|
Was dropping support for MCD cross-instance DPoP handle sharing intentional? |
This is intentional. In practice we still share the |
Background:
The proxy code reused shared fetcher state for requests to the same
audience. As part of that reuse, it replaced the fetcher’s token lookup function on every request. WhenDPoP nonceretry happened,request Acould pause,request Bcould come in and replace that function, and thenrequest A’sretry could continue usingrequest B’stoken.Fix:
This PR stops sharing request-specific token lookup state across requests. It now only reuses the
DPoPhandle peraudience, and creates a fresh fetcher for each request with that request’s own token lookup function. That keepsDPoP noncestate reusable, while making sure retries stay bound to the correct session.