fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080
visionik
·
2026-04-17
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -23,6 +23,34 @@ export const AUTH_STORE_LOCK_OPTIONS = {
|
23 | 23 | stale: 30_000, |
24 | 24 | } as const; |
25 | 25 | |
| 26 | +// Separate from AUTH_STORE_LOCK_OPTIONS for independent tuning: this lock |
| 27 | +// serializes the cross-agent OAuth refresh (see issue #26322), whereas |
| 28 | +// AUTH_STORE_LOCK_OPTIONS guards per-store file writes. Keeping them |
| 29 | +// distinct lets us widen the refresh lock's timeout/retry budget without |
| 30 | +// affecting the hot-path auth-store writers. |
| 31 | +// |
| 32 | +// Invariant: OAUTH_REFRESH_CALL_TIMEOUT_MS < OAUTH_REFRESH_LOCK_OPTIONS.stale |
| 33 | +// so a legitimate refresh's critical section always finishes well before |
| 34 | +// peers would treat the lock as reclaimable. Violating this invariant re- |
| 35 | +// introduces the `refresh_token_reused` race the lock is meant to prevent. |
| 36 | +export const OAUTH_REFRESH_LOCK_OPTIONS = { |
| 37 | +retries: { |
| 38 | +retries: 10, |
| 39 | +factor: 2, |
| 40 | +minTimeout: 100, |
| 41 | +maxTimeout: 10_000, |
| 42 | +randomize: true, |
| 43 | +}, |
| 44 | +stale: 180_000, |
| 45 | +} as const; |
| 46 | + |
| 47 | +// Hard upper bound on a single OAuth refresh call (plugin hook + HTTP |
| 48 | +// token-exchange). Any refresh that runs longer than this is aborted and |
| 49 | +// surfaced as a refresh failure. Keep strictly below |
| 50 | +// OAUTH_REFRESH_LOCK_OPTIONS.stale so the lock is never treated as stale |
| 51 | +// by a waiter while the owner is still doing legitimate work. |
| 52 | +export const OAUTH_REFRESH_CALL_TIMEOUT_MS = 120_000; |
| 53 | + |
26 | 54 | export const EXTERNAL_CLI_SYNC_TTL_MS = 15 * 60 * 1000; |
27 | 55 | export const EXTERNAL_CLI_NEAR_EXPIRY_MS = 10 * 60 * 1000; |
28 | 56 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。