fix: 複数ターミナル使用時の refresh token rotation 競合を解消#93
Conversation
複数ターミナルで同一プロファイルを使用している場合、一方のプロセスが refresh token rotation でトークンを更新すると、他方のプロセスが保持する 古い refreshToken が無効化されセッション切れとなっていた。 トークンリフレッシュ前に config ファイルを再読み込みする onBeforeRefresh コールバックを追加し、別プロセスが既にリフレッシュ済みの 場合はそのトークンを直接採用する。
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthroughマルチターミナルで同じプロファイルを使った際に発生するリフレッシュ競合を防ぐため、 Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client (GdbClient)
participant Config as External Config
participant Auth as Auth Server
Client->>Config: onBeforeRefresh() を呼ぶ\n(最新 token/refreshToken を取得)
alt Config has newer token
Config-->>Client: { token: newToken }
Client->>Client: this.token を更新してリクエスト再試行
Client->>Auth: API リクエスト (新しい token で)
Auth-->>Client: 200/成功
else Config has new refreshToken only
Config-->>Client: { refreshToken: newRefresh }
Client->>Auth: POST /auth/refresh (body.refresh_token = newRefresh)
alt refresh success
Auth-->>Client: { token, refreshToken }
Client->>Client: トークン保存/再試行
else refresh fails
Auth-->>Client: 401/失敗
Client-->>Client: エラーを返す (GdbClientError)
end
end
推定レビュー工数🎯 3 (Moderate) | ⏱️ ~25分 ポエム
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@CHANGELOG.md`:
- Line 11: The CHANGELOG entry for the fix ("**Fix**:
複数ターミナルで同一プロファイルを使用時、refresh token rotation によりセッションが無効化される問題を修正 — トークンリフレッシュ前に
config を再読み込みし、別プロセスが既にリフレッシュ済みならそのトークンを使用する") is missing the PR number suffix;
update that line in CHANGELOG.md to append the PR number in the standard format
(e.g. " (`#1234`)") at the end of the entry and ensure it sits under the correct
date group header.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4078861d-4d8e-4bb3-a70f-dde167d65ddb
📒 Files selected for processing (5)
CHANGELOG.mdsrc/client.tssrc/helpers.tssrc/types.tstests/client.test.ts
Summary
ClientOptionsにonBeforeRefreshコールバックを追加し、トークンリフレッシュ前に config ファイルを再読み込みBackground
Changes
src/types.ts:ClientOptionsにonBeforeRefreshを追加src/client.ts:doRefresh()冒頭でonBeforeRefreshを呼び、config の最新トークンを取得src/helpers.ts:createClient()でonBeforeRefreshにloadConfig()を接続tests/client.test.ts:onBeforeRefreshのテスト2件追加Test plan
onBeforeRefreshで別プロセスの更新済みトークンを採用するテストonBeforeRefreshで最新の refreshToken を使用するテストSummary by CodeRabbit
リリースノート
Bug Fixes
Tests