fix: 火山引擎弱网连接重试 + Windows 概率性「未配置」修复#722
Closed
appergb wants to merge 2 commits into
Closed
Conversation
added 2 commits
June 21, 2026 11:08
Windows Credential Manager(CredReadW)在登录后/并发下读 manifest+各 chunk 条目 时可能瞬时失败。任一条目读失败会让整组凭据看起来为空 → load_keyring_credentials 返回 Err → load_credentials 回退到空默认值 → 概览页显示「火山引擎未配置」,但下 一次听写重读成功,所以是「概率性」且「实际可正常使用」。凭据 chunk 越多,单次 load 读取次数越多,命中瞬时失败的概率越高。 修法:仅在 Windows 上对非 NoEntry 的读错误做几次短退避重试(4 次 / 60·n ms)。 NoEntry 是确定的「未存储」,立即返回不付重试延迟。macOS/Linux 保持原单次行为 ——它们的读错误是 ACL 拒绝,重试无益,且未缓存的错误路径下次调用本就会重读, 加 sleep 只会拖慢 macOS 首次 Keychain 授权流程。纯后端、cfg 隔离,零 PC-macOS 影响。
connect_async 此前既无超时也无重试:弱网下 TLS/WebSocket 握手可能挂到 OS 级 TCP 超时(几十秒),期间用户卡在「Starting」;而协调器全局超时只覆盖 await_final_result,不覆盖 open_session,所以握手挂起完全不受约束。单次网络 抖动(连接被重置/瞬时 DNS 失败)也会直接让整次听写失败。 修法:每次握手包 5s 超时,最多 3 次尝试、250·n ms 退避。AuthRejected(凭据被拒) 短路不重试——重试不会变好只会拖慢报错。把请求构造抽成 build_connect_request (connect_async 消费 request 且 http::Request 非 Clone,需每次重建)。 桌面与安卓共享此路径,改动对两端等效;最坏耗时从「无界(~75s)」降到有界(~15s) 并新增抖动可恢复,对 PC 端只增不减。
Contributor
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
Collaborator
|
已实现相同功能并推送至beta分支 并且针对所有来源渠道商而非单一火山引擎 并增加了队列处理等特性 |
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.
User description
背景
两个用户反馈的火山引擎接入问题,根因均已定位并修复。纯后端、外科手术式改动,对 PC 端只增不减、无 UI 改动。
问题 1:Windows 端概率性显示「火山引擎未配置」,但实际可正常使用
根因:Windows Credential Manager(
CredReadW) 在登录后/并发下读取凭据条目时会瞬时失败。凭据 v1 payload 按 1000 UTF-16 单位分片存成manifest + 多个 chunk条目;load_keyring_credentials顺序读每一条,任一条读失败就?抛错 →load_credentials回退到空默认值 → 概览页asrConfigured=false显示「未配置」。而错误路径不缓存,下一次听写重读成功,所以是概率性、且实际能用。chunk 越多,单次 load 读取次数越多,命中瞬时失败概率越高。修法(
persistence/credentials.rs):仅在 Windows 上,对非NoEntry的读错误做有限次短退避重试(4 次 / 60·n ms)。NoEntry是确定的「未存储」立即返回,不付重试延迟。macOS/Linux 保持原单次行为(cfg 隔离)——其读错误是 ACL 拒绝,重试无益,且会拖慢 macOS 首次 Keychain 授权流程。问题 2:网络环境较差时无法正常进行语音输入
根因:
open_session里的connect_async既无超时也无重试。弱网下 TLS/WS 握手可挂到 OS 级 TCP 超时(几十秒),用户卡在「Starting」;协调器全局超时只覆盖await_final_result,不覆盖 open_session。单次网络抖动也直接让整次听写失败。修法(
asr/volcengine.rs):每次握手包5s超时,最多3次尝试、250·n ms退避;AuthRejected(凭据被拒)短路不重试。请求构造抽成build_connect_request(connect_async消费 request 且http::Request非Clone,需每次重建)。最坏耗时从「无界(~75s)」降到有界(~15s),并新增抖动可恢复。桌面与安卓共享此路径,改动对两端等效。平台影响
#[cfg(target_os="windows")]隔离,macOS/Linux/Android 零变更。验证
cargo check通过(仅既有无关 warning)cargo test --lib458 passed / 0 failed🤖 Generated with Claude Code
PR Type
Bug fix
Description
Fix probabilistic "Volcengine not configured" on Windows by credential read retry
Fix session hang on poor network with connection timeout and retry
Diagram Walkthrough
flowchart LR subgraph Windows Credential Read A[Read credential] --> B{Success?} B -- Yes --> C[Return value] B -- No --> D{NoEntry?} D -- Yes --> E[Return None] D -- No --> F[Retry up to 4 times, 60ms backoff] F --> A end subgraph Volcengine Connection G[Connect with 5s timeout] --> H{Success?} H -- Yes --> I[Return WebSocket] H -- No --> J{AuthRejected? or max retries?} J -- Yes --> K[Return error] J -- No --> L[Sleep backoff, retry] L --> G endFile Walkthrough
volcengine.rs
Add timeout and retry for Volcengine WebSocket connectionopenless-all/app/src-tauri/src/asr/volcengine.rs
connect_with_retry
AuthRejected
credentials.rs
Retry transient Windows credential read failuresopenless-all/app/src-tauri/src/persistence/credentials.rs
attempts, 60ms backoff)