Skip to content

fix(host-runtime): retry replacing the remote socket lock record on Windows - #971

Closed
ump45nose wants to merge 1 commit into
BytePioneer-AI:mainfrom
ump45nose:pr/windows-socket-lock-rename
Closed

ump45nose wants to merge 1 commit into
BytePioneer-AI:mainfrom
ump45nose:pr/windows-socket-lock-rename

Conversation

@ump45nose

Copy link
Copy Markdown
Contributor

Summary

writeLockRecordAtomic publishes the remote socket lock record by renaming a complete temporary file over the register. On Windows, a reader that has the register open can make that rename fail briefly with EPERM, EACCES or EBUSY, and the publication fails even though the register is fine.

On Windows only, the rename is now retried a few times (10, 30, 70, 150, 300 ms) for those three codes, leaving the currently published register in place. Other errors, other platforms, and the final failed attempt still throw as before, and the temporary file is still removed in finally.

Related issues

N/A

Test plan

  • New remote-socket-lock.test.ts: a sharing violation is retried without removing the published register; retries are bounded for EACCES and the guarded action never runs after a failed publication; non-Windows errors are not retried. On current main without the fix, the two Windows cases fail; with the fix all 3 pass. npx tsc -b passed.
  • The tests mock process.platform and rename; I have not run this on a real Windows machine.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • 修复
    • Windows 上发布远程连接锁遇到可恢复的文件操作错误时会自动重试,减少短暂文件占用导致的操作失败。
    • 重试期间保留现有锁记录;若重试仍失败,操作会报错且不会执行后续操作。

writeLockRecordAtomic 现在会在 Windows 上遇到指定重命名错误时延迟重试。新增测试覆盖重试成功、重试耗尽和其他错误的处理。

Changes: Windows 锁记录发布

层 / 文件 摘要
发布重试与验证
packages/host-runtime/src/remote-socket-lock.ts, packages/host-runtime/test/remote-socket-lock.test.ts
Windows 上遇到 EPERM、EACCES 或 EBUSY 时,发布逻辑按 10、30、70、150、300 毫秒间隔重试。测试覆盖 EPERM 重试成功,以及 EACCES 和 EIO 导致发布失败的情况。

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

Change: Bug fix

Possibly related PRs

Suggested labels: 类型:缺陷修复

Suggested reviewers: mouzhi

Merge Risk: Minimal · up to af23f

This change makes publishing the remote socket lock record more resilient to temporary Windows file-sharing conflicts. Failure behavior elsewhere is unchanged. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed 标题准确描述了主要变更:在 Windows 上为替换远程 socket 锁记录的 rename 操作增加重试。标题与 writeLockRecordAtomic 的重试逻辑、以及新增测试一致。标题简洁,包含 fix 类型和模块范围。
Description check Passed 描述与变更内容直接相关。描述说明了 writeLockRecordAtomic 在 Windows 上对 EPERM、EACCES、EBUSY 的重试间隔、保留已发布寄存器的行为、非 Windows 平台及最终失败的处理方式,并列出了新增测试和验证情况。
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
Fix failing CI checks

  • 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 528f9db and af23f01.

Files selected for processing: 2

  • packages/host-runtime/src/remote-socket-lock.ts
  • packages/host-runtime/test/remote-socket-lock.test.ts

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

Recent review details

Context from checks skipped due to timeout: 8

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

Code guidelines: 2

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

Source excerpt: Host Runtime loads installed plugins through public contracts, not direct imports of concrete Adapter packages.

CodeRabbit inference engine (AGENTS.md)

Files:

  • packages/host-runtime/src/remote-socket-lock.ts
  • packages/host-runtime/test/remote-socket-lock.test.ts

ump45nose added a commit to ump45nose/codex-host that referenced this pull request Nov 20, 2026
Every manifest line is now a branch with only its own change, cut from v0.22.0 or from the one branch named in its comment. Drops lines upstream v0.22.0 already has (BytePioneer-AI#913-BytePioneer-AI#917), the covered replay-integration, shared-remote-threads-and-delegation (now thin BytePioneer-AI#970/BytePioneer-AI#971/BytePioneer-AI#972 lines), external-side-chat (now thin BytePioneer-AI#969), remote-ssh-share-local-data, the net-zero Claude Desktop entrypoint pair, and the user-instructions lines rejected upstream as BytePioneer-AI#741. rr-cache holds the recorded resolutions for merging the thin branches onto v0.22.0.

Signed-off-by: Vincent <[email protected]>
@BytePioneer-AI

Copy link
Copy Markdown
Owner

Thanks @ump45nose for digging into this. Closing because the Windows branch is not reachable from production today: both callers of the socket initialization lock sit behind process.platform !== "win32" (packages/host-runtime/src/remote-app-server.ts around lines 399 and 434), and the SSH remote Host doc lists Windows remotes as unsupported. If we add a Windows caller later, the same retry strategy (it matches harness-display-settings.ts and #995) is the right starting point.

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