Skip to content

fix(deepseek-harness): keep fault cleanup failures from crashing the Host - #935

Merged
BytePioneer-AI merged 1 commit into
BytePioneer-AI:mainfrom
lpmasser:fix/deepseek-fault-close-rejection
Nov 21, 2026
Merged

BytePioneer-AI merged 1 commit into
BytePioneer-AI:mainfrom
lpmasser:fix/deepseek-fault-close-rejection

Conversation

@lpmasser

Copy link
Copy Markdown
Contributor

Summary

DeepSeek Harness 的连接出故障时,Adapter 在 #fail() 里启动清理(#performClose(failure)),把这个 Promise 存进 #closePromise,但当时没有任何调用方等待它。如果某个 Session 在故障时可能还有原生执行(#faultMayHaveNativeWork),它的 close() 会以 “native execution stop was not confirmed before the Session fault” 拒绝,#performClose 再把这个失败抛出。这个拒绝没有处理者,Node 按默认行为让共享 Host 以 code 1 退出,Codex Desktop 随之重启,其他 Harness 正在进行的任务也被打断。

实际日志(Host Runtime):

DeepSeek Harness Session faulted: DeepSeek Harness journal live follow failed: DeepSeek Harness Remote stream closed unexpectedly
FATAL unhandledRejection: Error: DeepSeek Harness native execution stop was not confirmed before the Session fault
    at async Promise.allSettled (index 0)
    at async #performClose (.../plugins/deepseek-harness/plugin.mjs)
Host Runtime exited with code 1

修法:故障路径存下清理 Promise 时把它标记为已处理。失败仍保存在 #closePromise 中,之后调用 close() 的一方照常收到这个拒绝,不改变清理顺序和错误语义。

Test plan

  • 新增用例 “keeps a cleanup failure after a connection fault for close instead of the process”:连接故障后清理失败时不产生 unhandled rejection,随后的 close() 仍以该失败拒绝。修复前该用例失败(unhandledRejection 被触发)。
  • npx vitest run --config tests/vitest.config.js packages/adapters/deepseek-harness/test/modern/deepseek-harness-adapter.test.ts:73 个用例通过。
  • 改动文件 eslint/prettier 退出 0。

…Host

A connection fault starts adapter cleanup that nobody awaits. When a
session could not confirm its native work stopped, that cleanup
rejected unhandled and Node exited the shared Host, restarting Codex.
Mark the stored cleanup handled; close() still reports the failure.
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug 修复
    • 修复连接故障后的清理错误处理:关闭操作可返回清理错误,且不会产生未处理的 Promise 拒绝。

连接故障时,适配器现在会为故障清理 Promise 附加拒绝处理器。新增测试验证清理错误由 adapter.close() 返回,且不会产生未处理的 Promise rejection。

Changes: 连接故障清理

Layer / File(s) Summary
故障清理与错误验证
packages/adapters/deepseek-harness/src/modern/deepseek-harness-adapter.ts, packages/adapters/deepseek-harness/test/modern/deepseek-harness-adapter.test.ts
#fail 在尚无 #closePromise 时启动并保存故障清理,并为清理 Promise 附加拒绝处理器。测试验证 adapter.close() 返回连接关闭错误,且不会产生未处理的 Promise rejection。

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: omsd512-w, bytepioneer-ai

Merge Risk: Minimal · up to 9f3c9

The change prevents a cleanup failure after a connection fault from crashing the shared Host, and the failure is still reported through close(). No material merge risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed 标题“fix(deepseek-harness): keep fault cleanup failures from crashing the Host”准确描述了主要变更:修复 DeepSeek Harness 故障清理失败导致共享 Host 崩溃的问题。摘要显示改动集中在 #fail() 中对 #closePromise 的处理,并新增对应测试,二者一致。
Description check Passed 描述与变更内容相关。它说明了连接故障后 #fail() 启动清理并保存 #closePromise 的问题,给出了 unhandledRejection 的实际日志,描述了修复方式(将故障路径的清理 Promise 标记为已处理)以及新增的测试用例和验证结果,与 raw_summary 中的改动一致。
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between d3e61d7 and 9f3c964.

Files selected for processing: 2

  • packages/adapters/deepseek-harness/src/modern/deepseek-harness-adapter.ts
  • packages/adapters/deepseek-harness/test/modern/deepseek-harness-adapter.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.

Recent review details

Context from checks skipped due to timeout: 8

  • GitHub Check: CodeRabbit
  • GitHub Check: Check windows-latest
  • GitHub Check: Check macos-26
  • GitHub Check: Vitest
  • GitHub Check: Static checks
  • GitHub Check: Check ubuntu-22.04
  • GitHub Check: Web Host tests
  • GitHub Check: Check Linux ARM64
Additional context used

Code guidelines: 2

AGENTS.md — auto-discovered
CLAUDE.md — auto-discovered
Path-based instructions: 2

Source excerpt: Harness-specific protocol details must remain inside the corresponding Adapter.

CodeRabbit inference engine (AGENTS.md)

Files:

  • packages/adapters/deepseek-harness/src/modern/deepseek-harness-adapter.ts
  • packages/adapters/deepseek-harness/test/modern/deepseek-harness-adapter.test.ts
Source excerpt: `codexhost` runs external Agent Harnesses as independent Threads inside Codex Desktop, preserving the official shell and native Codex path.

CodeRabbit inference engine (CLAUDE.md)

Files:

  • packages/adapters/deepseek-harness/src/modern/deepseek-harness-adapter.ts
  • packages/adapters/deepseek-harness/test/modern/deepseek-harness-adapter.test.ts

@BytePioneer-AI
BytePioneer-AI merged commit 9919915 into BytePioneer-AI:main Nov 21, 2026
8 checks passed
@BytePioneer-AI

Copy link
Copy Markdown
Owner

Merged, thanks @lpmasser! Keeping the fault-cleanup rejection for a later close() instead of letting it crash the Host is the right fix. Note for #949: it carries the same .catch, so it will need a rebase on top of this.

@lpmasser
lpmasser deleted the fix/deepseek-fault-close-rejection branch November 21, 2026 14:19
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