We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 68d2f0d + 35cf70f commit 5420dc3Copy full SHA for 5420dc3
1 file changed
lib/app_auth.ts
@@ -19,6 +19,7 @@ export interface AppAuth {
19
export class AppTokenManager {
20
private token: string | null = null
21
private tokenExpiresAt: number = 0
22
+ private pending: Promise<string> | null = null
23
24
constructor(private auth: AppAuth) {}
25
@@ -27,7 +28,14 @@ export class AppTokenManager {
27
28
return this.token
29
}
30
- return await this.authenticate()
31
+ if (this.pending) {
32
+ return await this.pending
33
+ }
34
+
35
+ this.pending = this.authenticate().finally(() => {
36
+ this.pending = null
37
+ })
38
39
40
41
private async authenticate(): Promise<string> {
0 commit comments