improvement(oauth): coalesce token refresh + cache terminal failures#4706
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Refresh failure handling is hardened. New concurrency utilities and tests added. Introduces Reviewed by Cursor Bugbot for commit b424129. Configure here. |
74180a1 to
9a07693
Compare
Greptile SummaryThis PR eliminates the OAuth token-refresh race condition by introducing a two-layer coalescing strategy:
Confidence Score: 5/5Safe to merge; the coalescing logic is well-tested and all Redis operations degrade gracefully to pre-PR behaviour when unavailable. The concurrency primitives are correct, the fallback paths (Redis down → uncoordinated leader, lock release failure → TTL expiry) are exercised by tests, and all four refresh call sites now go through the coalesced path. The one non-blocking concern is that a handful of OAuth app-level error codes in the terminal set could cause user-visible reconnect requirements after a server misconfiguration. apps/sim/lib/oauth/terminal-errors.ts — the TERMINAL_ERRORS set includes app-level OAuth config errors alongside user-level credential errors. Important Files Changed
Reviews (4): Last reviewed commit: "improvement(oauth): coalesce token refre..." | Re-trigger Greptile |
9a07693 to
5669c4f
Compare
5669c4f to
3554a5d
Compare
3554a5d to
d6b870f
Compare
|
@greptile |
|
@cursor review |
d6b870f to
b6c7967
Compare
b6c7967 to
92b42c1
Compare
92b42c1 to
99d9265
Compare
|
@greptile |
|
@cursor review |
99d9265 to
b424129
Compare
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit b424129. Configure here.
Summary
account.idso concurrent workflow runs trigger exactly one provider call instead of racing — fixes 201 silentinvalid_refresh_tokenerrors / 30d for Slack alone{ok: false}body errors inrefreshOAuthToken(previously silently dropped to WARN with noproviderId)invalid_refresh_token,access_denied, etc.) for 1h to stop futile retry storms; flag clears on reconnectperformCoalescedRefreshhelper consolidates the three refresh call sites; reuses existingacquireLock/releaseLock+redisConfigMockfrom@sim/testingType of Change
Testing
lib/concurrency/__tests__/singleflight.test.ts,lib/concurrency/__tests__/leader-lock.test.ts,lib/oauth/__tests__/terminal-errors.test.tsaddedChecklist