Skip to content

fix(debug): preserve hosted stream for disconnect after cancellation - #2445

Merged
1lck merged 2 commits into
mainfrom
devin/1795696080-1981-announced-disconnect
Nov 27, 2026
Merged

1lck merged 2 commits into
mainfrom
devin/1795696080-1981-announced-disconnect

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

关联 Issue / Linked issue

PR 类型 / Type

  • feat
  • fix
  • docs
  • release

改动说明 / What changes

背景 / Why

停止托管 TCP 调试会话时,会话取消可能先触发迟到写入登记的关闭回调,使清理任务无法把 DAP disconnect 放入队列,适配器随即退出而没有报告断连。

改动 / Changes

  • 将每次写入的取消关闭回调限定到 *os.File 标准输入管道,保留阻塞写入的超时与取消中断。
  • 托管 TCP 写入检查会话取消并返回错误,连接由 Core 驱动的停止排空流程负责关闭。
  • 新增使用真实 Core 状态机、net.Pipe 和 testing/synctest 的回归,固定“连接就绪 → 取消会话 → 迟到写入 → 发送断连 → 排空”的顺序,并检查对端收到完整断连内容。
  • 更新调试清理 Agent Note 和 debug-tcp-transport 功能矩阵的验证说明、行为约束及证据路径。

不在本 PR 范围内 / Out of scope

无。


类型专属:fix

复现与根因

  • 在 main 5bdb7d36e 上运行原始 TestDebugAnnouncedAdapterBreakpointPauseContinueStop,Linux 连续 100 次通过。该 issue 的自然失败来自 macOS。
  • 新回归在未修改的实现上连续 5 次失败,输出为 queuing disconnect after cancellation: the debug adapter stream is not running。期望适配器在停止时收到断连帧。
  • writeFrames 原先为每种传输登记 context.AfterFunc(... transport.Close)。会话已经取消时,该回调会先关闭托管 TCP 连接,随后清理任务的 disconnect 入队失败。
  • git blame 定位到 0faecba49(Epic(0.7.0): 基于 Viva 框架的跨平台方案的迁移(#1794) #1799)引入这段写入关闭逻辑。feat(desktop): 托管 tcpAnnounced 调试适配器 #1954 接入 tcpAnnounced 托管进程后也使用它。
  • 影响 macOS 和 Windows 共用的 Viva 桌面传输实现。本次本地运行环境为 Ubuntu 22.04.5 x86_64,Go 1.27.4,固定 Core c269c41153c8da2f2e8d064c68550a8f23260e2c。

检查项

  • 回归先失败后通过。新增测试位于 desktop/internal/workbench/debug_transport_test.go,修复前 5/5 失败,修复后与原始完整调试流程、stdio 阻塞取消测试各通过 100 次。
  • [N/A] 手动复现步骤。已有自动化回归。
  • 已检查 writeFrames 全部调用方、setTransport 的全部写入端安装点,以及会话取消、清理排空和进程退出路径。
  • macOS 和 Windows 使用同一实现,修复覆盖共用代码。
  • 改动集中在本次断连问题,检查范围内未发现需要另建单的其他问题。
  • 已更新 .agents/notes/implemented/bug-fix/2026-11-09-viva-debug-session-cleanup.md。

范围检查 / Scope checks

功能矩阵 / Feature matrix

  • 已更新 shared/platform-feature-matrix/features/debug-tcp-transport.json,两端原生验证状态如实保持 pending。
  • 已运行矩阵生成、验证和相对 origin/main HEAD 的实质变更门禁。
  • 生成视图位于本地 .artifacts/platform-feature-matrix/,提交清单仅含四个源码和决策记录文件。
  • [N/A] 矩阵豁免。已有对应能力记录变更。

插件归属 / Plugin ownership

  • 已运行 develop-lithe 的全仓库自查命令,命中数为 0。
  • 新回归只用内存连接与 Core,原工作台回归使用测试内联合成适配器。
  • 功能矩阵记录通用宿主传输能力,证据引用宿主实现与宿主测试。
  • 改动中的文档和矩阵均围绕通用宿主传输。
  • [N/A] 具体插件测试。本次修改原生传输关闭时序,验收使用合成适配器。

UI 验证 / UI evidence

N/A。本次修改位于调试字节流和清理路径。完整断点、暂停、继续和停止通过既有无头工作台回归验证。

统一日志系统 / Structured logging

取消通过 context.Canceled 返回,失败仍由调用方的 debugWriteFailed 等边界处理。仓库旧 scripts/logging/ 校验脚本已移除,等价日志静态门禁未完成。

界面文案 / i18n

  • [N/A] 宿主文案词条。本次改动由传输代码、测试和决策记录组成。
  • [N/A] 插件文案。
  • 已运行应用语言校验与 i18n 生成结果检查。

逻辑归属 / Logic placement

  • Core 负责传输状态、队列预算、超时和排空。此次 Go 修改负责识别原生 *os.File 并用关闭文件句柄中断 OS 写入。
  • [N/A] 平台共享业务逻辑迁移。本次修改的是原生 I/O 取消回调的资源归属。
  • 通用字节流逻辑由现有 Core 状态机提供。

性能与内存 / Performance and memory

N/A。本次移除托管写入上的临时 context、定时器和关闭回调分配,stdio 仍按原生阻塞写入需要创建它们。

设置 / Settings

N/A。

插件契约 / Plugin contract

N/A。

发行包与资源 / Bundle and resources

  • 已运行发行目录只读检查。
  • [N/A] 新增下载、解压、缓存或资源路径。

无用代码与重构 / Dead code and refactoring

  • [N/A] 本次改动产生的无用代码。
  • [N/A] 检查范围内需提交 refactor Issue 的既有问题。

验证 / Verification

命令或操作 平台 结果
新增确定性回归,未修改生产代码时 -count=5 Linux 5/5 失败,断连入队时报 stream is not running
新回归、TestDebugAnnouncedAdapterBreakpointPauseContinueStop、TestDebugBlockedWriteEndsOnCancellation,-count=100 Linux 全部通过
Go timing harness,-run '^(TestDebug|TestHosted)',串行执行 Linux 82 项通过,2 个仅供子进程调用的 Runner 入口按预期跳过。最慢 420ms,新回归小于 10ms
scripts/desktop/desktop-go.sh test -race ./internal/workbench -run '^(TestDebug|TestHosted)' -count=1 -timeout=300s Linux 通过
scripts/desktop/desktop-go.sh test ./... -count=1 -timeout=900s Linux 全部通过,workbench 包 242.839s
scripts/desktop/desktop-go.sh vet ./... Linux 通过
./.agents/skills/write-stable-tests/scripts/verify-test-stability.sh --base origin/main Linux Go 静态覆盖 N/A,已手工检查等待、取消和资源清理,并运行 Go timing/race
node scripts/i18n/verify-app-language-localization.mjs、node scripts/i18n/generate-i18n.mjs --check Linux 通过
./scripts/agent-notes/verify-agent-notes.sh Linux 通过
node scripts/platform-feature-matrix/generate-platform-feature-matrix.mjs、矩阵 verify、change gate Linux 通过
./scripts/desktop/verify/verify-runtime-bundle-immutability.sh、插件归属自查、git diff --check Linux 通过

本地 timing HTML/JUnit 报告已生成于 .artifacts/test-stability/,包含新增回归的逐项耗时。

Ready 后的 GitHub Actions 已完成。macOS、Windows 和 Linux 的 Vet and test 均通过。Format and script tests 的发行包只读校验脚本自测失败,汇总门禁因此为红。校验脚本需要 Dev Container 工作流,但自测夹具少了对应的样例。在本地运行 node --test scripts/desktop/verify/test-runtime-bundle-immutability.mjs 得到相同失败,基线 5bdb7d36e 的 CI 也有同一报错。#2444 已补齐该夹具。本 PR 的检查 · 基线失败 · 夹具修复

未能执行的检查和原因

  • 当前 VM 为 Linux,100 次重复验证在这台机器完成。macOS、Windows 已通过 CI 桌面套件,实际安装包的人工端到端验收未执行。
  • Go 静态稳定性扫描当前未覆盖桌面测试,已运行其要求的计时、竞态检查,并人工审查新增测试的确定性同步与清理。
  • 仓库已移除的日志静态校验门禁尚未恢复。

提交前确认 / Final checks

  • 分支从本次开始时最新的 main 创建,目标分支为 main。
  • 以 Draft 提交,本地验证通过后已标记 ready。
  • 已核对四个文件的提交范围。
  • 本次测试进程已全部退出。

Written by Devin

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@ghfind-review ghfind-review Bot added the review: no-score ghfind author score missing (not zero) label Nov 26, 2026
@devin-ai-integration
devin-ai-integration Bot marked this pull request as ready for review November 26, 2026 12:46

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Devin Review: 2 flags

Not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)

Devin Review

@1lck
1lck merged commit d29ea54 into main Nov 27, 2026
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review: no-score ghfind author score missing (not zero)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] macOS 整包测试偶发无法观察到 tcpAnnounced 适配器的 disconnect

1 participant