Skip to content

test(remote-control): add reconnect failure diagnostics to tunnel scenario - #4605

Merged
sailist merged 1 commit into
mainfrom
bug-322-11-02-remote-control-reconnect-timeout
Nov 2, 2026
Merged

sailist merged 1 commit into
mainfrom
bug-322-11-02-remote-control-reconnect-timeout

Conversation

@sailist

@sailist sailist commented Nov 2, 2026

Copy link
Copy Markdown
Collaborator

Requirement or Bug

remote-control.test.ts 的 "reconnects the tunnel pair after the relay drops it" 用例在 GitHub CI 高负载分片上出现过 30 秒整体超时(run 41394309765,shard 4),重跑即通过;m0-dev 单用例 20 次、整文件 5 次均稳定通过,判定为时序/负载敏感的 flaky。失败时几乎没有定位线索:scenario 把客户端 stderr 全部丢弃,且重连后的响应等待是无超时的 nextJsonMessage。本 PR 只补充测试可观测性,让下一次失败自带诊断,不改任何产品行为。

Bug Reproduction Steps

N/A(测试基建改动;flaky 背景见上节与 handoff 记录)

Root Cause

N/A

Code Changes

核心思路:把"挂死且零信息"的失败形态改成"有界等待 + 失败时完整现场",全部改动在 packages/remote-control/test/remote-control.test.ts:

 startTunnelScenario
-  stderr: { write: () => true }        // 客户端日志被吞
+  stderr 收集到闭包,TunnelScenario 新增 logs getter 暴露

 nextJsonMessage(socket)
-  无限等待 message(可撑满 30s 测试超时)
+  默认 10s 有界等待,超时抛出明确错误

 用例 reconnects the tunnel pair after the relay drops it
+  整体 try/catch:失败时抛出 registrations/httpConnections 计数、
+  各 socket readyState、完整客户端日志(cause 保留原错误)

三处配合后,若 CI 再次出现同类失败,日志会直接显示卡在哪一步、客户端视角的断连/重连/消息错误过程,便于确诊是丢帧、等错连接还是环境缓慢。未采用"加大 waitFor/超时预算"的掩盖式修法:若响应真的不来,等更久照样失败。

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
nextJsonMessage 等待上限 无超时(最坏撑满用例 30s 超时) 默认 10s,超时抛出带时长的错误 仅测试内部 helper;14 个调用点均为发请求后立即等响应,正常路径毫秒级返回 不需要
scenario 客户端 stderr 丢弃 收集到 scenario.logs(仅目标用例失败时输出) 无 —
目标用例失败信息 仅 vitest 30s 超时 附带 relay 连接状态与客户端日志的诊断错误 无 —
产品代码与被测行为 — 完全不变 — —

受影响模块与测试覆盖:仅 packages/remote-control/test/remote-control.test.ts。验证结论:本地整文件 51/51 通过;tsc --noEmit 通过;oxlint 与注释检查无新增告警。未验证项:真实 CI 高负载下的失败形态改善只有等下次(不再)失败才能确认,这是本改动的预期用途而非遗漏。

本地验证命令
  • corepack pnpm vitest run test/remote-control.test.ts:51/51 通过
  • corepack pnpm exec tsc --noEmit:通过
  • oxlint(改动文件):0 warnings / 0 errors
  • node scripts/check-no-comments.mjs:OK

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Nov 2, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: c85ac29

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T06:18:48.139013Z c85ac29 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Nov 2, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@c85ac29
npx https://pkg.pr.new/@moonshot-ai/kimi-code@c85ac29

commit: c85ac29

@sailist
sailist merged commit 9ce252a into main Nov 2, 2026
161 checks passed
@sailist
sailist deleted the bug-322-11-02-remote-control-reconnect-timeout branch November 2, 2026 08:02
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Nov 4, 2026
… as already landed

MoonshotAI#4434's CSP already allows data: and blob: media fetches, MoonshotAI#4517's
[workspace] require_trust section and its store short-circuit are in the
tree with both locale docs, and MoonshotAI#4605's tunnel scenario already reports
httpCapabilities and asserts the reconnected response.

Ledger: closed 28 -> 32, remaining 67.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants