Single-flight refresh
Only one refresh runs at a time: the first 401 starts it and stores the promise, and every other request that fails meanwhile awaits the same promise. With rotating refresh tokens, parallel refreshes would invalidate each other and sign the user out.
Minimal example
if (!this.refreshing) this.refreshing = doRefresh().finally(() => (this.refreshing = null));
return this.refreshing;Learn this concept
Lesson 4.6 · Single-flight API refreshUsed in exercises
Exercise 4.7 · API client and auth screensPrerequisite conceptsSilent refresh