Changesets · Branches · Tags · Compare
| Changeset | 4248554ef60b4c8ca36af54aabb7e19e8a17353b3ae1ff2175f0807a98687bac |
|---|---|
| Author | Nate <sestinj@gmail.com> · 2025-07-07 23:01 -07:00 |
| Committer | Nate <sestinj@gmail.com> · 2025-07-07 23:01 -07:00 |
| Parents | 3389e73db7c2 |
1 file changed
modified extensions/vscode/src/stubs/WorkOsAuthProvider.ts +7 −12
| @@ -229,7 +229,6 @@ | ||
| 229 | 229 | private async _refreshSessionWithRetry( |
| 230 | 230 | refreshToken: string, |
| 231 | 231 | attempt = 1, |
| 232 | - maxAttempts = 3, | |
| 233 | 232 | baseDelay = 1000, |
| 234 | 233 | ): Promise<{ |
| 235 | 234 | accessToken: string; |
| @@ -243,26 +242,22 @@ | ||
| 243 | 242 | if ( |
| 244 | 243 | error.message?.includes("401") || |
| 245 | 244 | error.message?.includes("Invalid refresh token") || |
| 246 | - error.message?.includes("Unauthorized") || | |
| 247 | - attempt >= maxAttempts | |
| 245 | + error.message?.includes("Unauthorized") | |
| 248 | 246 | ) { |
| 249 | 247 | throw error; |
| 250 | 248 | } |
| 251 | 249 | |
| 252 | 250 | // For network errors or transient server issues, retry with backoff |
| 253 | 251 | // Calculate exponential backoff delay with jitter |
| 254 | - const delay = | |
| 255 | - baseDelay * Math.pow(2, attempt - 1) * (0.5 + Math.random() * 0.5); | |
| 252 | + const delay = Math.min( | |
| 253 | + baseDelay * Math.pow(2, attempt - 1) * (0.5 + Math.random() * 0.5), | |
| 254 | + 60 * 60 * 1000, // 1 hour in milliseconds | |
| 255 | + ); | |
| 256 | 256 | |
| 257 | 257 | // Schedule retry after delay |
| 258 | 258 | return new Promise((resolve, reject) => { |
| 259 | 259 | setTimeout(() => { |
| 260 | - this._refreshSessionWithRetry( | |
| 261 | - refreshToken, | |
| 262 | - attempt + 1, | |
| 263 | - maxAttempts, | |
| 264 | - baseDelay, | |
| 265 | - ) | |
| 260 | + this._refreshSessionWithRetry(refreshToken, attempt + 1, baseDelay) | |
| 266 | 261 | .then(resolve) |
| 267 | 262 | .catch(reject); |
| 268 | 263 | }, delay); |
| @@ -357,7 +352,7 @@ | ||
| 357 | 352 | |
| 358 | 353 | return session; |
| 359 | 354 | } catch (e) { |
| 360 | - window.showErrorMessage(`Sign in failed: ${e}`); | |
| 355 | + void window.showErrorMessage(`Sign in failed: ${e}`); | |
| 361 | 356 | throw e; |
| 362 | 357 | } |
| 363 | 358 | } |