fix: accurate token expiration detection, retry optimization, and state consistency (#308)#312
Open
hzexe wants to merge 2 commits intochenyme:mainfrom
Open
fix: accurate token expiration detection, retry optimization, and state consistency (#308)#312hzexe wants to merge 2 commits intochenyme:mainfrom
hzexe wants to merge 2 commits intochenyme:mainfrom
Conversation
added 2 commits
March 12, 2026 09:53
…retries/fallback for expired tokens (chenyme#308)
…r, and eliminate stale data on refresh (chenyme#308)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
修复了 Token 管理中的状态同步不一致问题(Issue #308),优化了 401
错误码的识别逻辑(区分业务过期与网络层拦截),并修复了在高频刷新场景下的数据一致性问题及日志系统的一个潜在崩溃 Bug。
Fixed token state synchronization issues (#308), optimized 401 error identification (distinguishing business expiry
from network interception), and resolved data consistency issues during high-frequency refreshes along with a logging
system bug.
Changes
Related Issues
Closes #308
Verification
验证说明:
1 - 启动服务后,手动刷新已过期的 Token,管理面板能即时显示 expired 状态,不再弹出“刷新失败”错误。
2 - 确认日志中不再出现 KeyError: '"code"',即便上游返回的 Body 包含大括号。
3 - 确认 /admin/tokens 接口返回的数据与内存状态实时同步,解决了刷新后页面显示“脏数据”的问题。
Breaking Changes
详细说明 (Detailed Explanation)
为了解决 Issue bug: 错误的token,选中刷新状态任然是active #308 中 Token 状态不更新的问题,我们对 401 错误进行了深度细化区分:
在其他网络环境下重试的机会。
内存中获取状态。由于内存状态是实时的,解决了刷新后立即查询存储导致的“脏数据”问题。
'"code"'。改用参数化日志记录方式,提升了系统的健壮性。