fix(network): harden manual host add timeout handling - #36
Conversation
|
Warning Review limit reached
More reviews will be available in 14 minutes and 29 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 Walkthrough概览PR 通过引入 options 对象,统一重构 NvHttp 的请求接口(超时、证书参数),并改进 ComputerManager 的计算机添加流程以支持手动添加时的鲁棒重试和 mDNS 发现时的参数传递,同时优化了轮询时的上线状态检测。 变更详情HTTP 请求参数化与计算机添加流程重构
审查工作量评估🎯 3 (中等) | ⏱️ ~20 分钟 可能相关的 PR
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
entry/src/main/ets/service/streaming/NvHttp.ets (1)
489-496: 💤 Low value参数
timeout未被使用。
doHttpsWithFrpRetry的timeout参数(第492行)在函数体内从未被引用。实际的传输超时由调用方通过requestlambda 闭包捕获。建议移除此冗余参数以避免混淆。♻️ 建议移除未使用参数
private async doHttpsWithFrpRetry<T>( path: string, query: string | undefined, - timeout: number, request: (url: string) => Promise<T>, connectTimeout: number = NvHttp.CONNECTION_TIMEOUT ): Promise<T> {同时更新调用方:
- return this.doHttpsWithFrpRetry(path, options?.query, transferTimeout, (url: string): Promise<string> => { + return this.doHttpsWithFrpRetry(path, options?.query, (url: string): Promise<string> => {🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@entry/src/main/ets/service/streaming/NvHttp.ets` around lines 489 - 496, Remove the unused timeout parameter from doHttpsWithFrpRetry: update the method signature (function doHttpsWithFrpRetry<T>(path: string, query: string | undefined, request: (url: string) => Promise<T>, connectTimeout: number = NvHttp.CONNECTION_TIMEOUT): Promise<T>) and all call sites that pass a timeout to stop supplying that argument; leave the request lambda as-is (it already captures any needed per-call timeout) and keep connectTimeout's default behavior unchanged so no other internal logic needs modification.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@entry/src/main/ets/service/streaming/NvHttp.ets`:
- Around line 489-496: Remove the unused timeout parameter from
doHttpsWithFrpRetry: update the method signature (function
doHttpsWithFrpRetry<T>(path: string, query: string | undefined, request: (url:
string) => Promise<T>, connectTimeout: number = NvHttp.CONNECTION_TIMEOUT):
Promise<T>) and all call sites that pass a timeout to stop supplying that
argument; leave the request lambda as-is (it already captures any needed
per-call timeout) and keep connectTimeout's default behavior unchanged so no
other internal logic needs modification.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 38bdd4a4-7634-4786-b841-765f651de66b
📒 Files selected for processing (2)
entry/src/main/ets/service/ComputerManager.etsentry/src/main/ets/service/streaming/NvHttp.ets
9fe198e to
99d6b64
Compare
改了啥呀
/serverinfo探测遇到瞬时网络错误会快速重试一次,专治那种一次 timeout 就装死的杂鱼状态。NvHttp.getServerInfo(likelyOnline)现在真的会按likelyOnline选择 5s/3s 连接超时,并让 HTTPS 端口懒解析、HTTP 降级沿用同一连接超时。undefined, true这种读起来会绊脚的参数排列。为啥要改
用户反馈手动添加主机时报
HTTP 请求失败: Timeout was reached,但 Android 客户端同一时间可以连接。对照 Android 后发现我们有几处更容易放大 HarmonyOS/RCP 偶发超时的问题:手动添加没有轻量重试,likelyOnline参数没有实际接入连接超时策略,轮询调用也没有区分活跃在线地址。验证
git diff --check$env:DEVECO_SDK_HOME='C:\Program Files\Huawei\DevEco Studio\sdk'; $env:JAVA_HOME='C:\Program Files\Huawei\DevEco Studio\jbr'; $env:PATH="$env:JAVA_HOME\bin;$env:PATH"; & 'C:\Program Files\Huawei\DevEco Studio\tools\hvigor\bin\hvigorw.bat' --no-daemon assembleHap构建已通过。现有项目级 ArkTS warning 仍然存在,但不是这次改动引入的,杂鱼 warning 们先排队。