Skip to content

fix: tolerate Windows reserved launcher ports#1293

Open
577fkj wants to merge 1 commit into
BigPizzaV3:mainfrom
577fkj:main
Open

fix: tolerate Windows reserved launcher ports#1293
577fkj wants to merge 1 commit into
BigPizzaV3:mainfrom
577fkj:main

Conversation

@577fkj

@577fkj 577fkj commented Jul 1, 2026

Copy link
Copy Markdown

Fix Codex++ startup failure caused by a Windows-reserved port.

Copilot AI review requested due to automatic review settings July 1, 2026 16:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

该 PR 旨在修复 Windows 上因“端口被系统保留/禁止绑定”导致的 Codex++ 启动失败问题:当 loopback 端口 bind 返回权限相关错误时,不再直接失败,而是退回到文件锁机制保证单实例;同时补充诊断日志以便定位启动/等待流程中的非致命失败。

Changes:

  • LoopbackPortGuard 获取逻辑在 AddrInUse 之外,新增对“禁止绑定(权限/WSAEACCES)”场景的锁回退处理,并补充单测覆盖该分支。
  • Windows packaged activation 等待进程 ID 失败时改为记录诊断日志并继续(非致命)。
  • Launcher 侧在激活已存在 Codex 实例时使用“选择后的 helper 端口”,并记录 requested/selected 端口到诊断日志;同时为 launcher 顶层失败增加统一诊断日志。

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
crates/codex-plus-core/src/ports.rs 对端口 bind 被禁止的场景走 fallback lock,并增加对应单测
crates/codex-plus-core/src/launcher.rs packaged 进程等待失败改为非致命,并写入诊断日志
apps/codex-plus-launcher/src/main.rs 顶层失败写诊断日志;激活已存在实例时使用选定 helper 端口并增强日志字段

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 51 to 53
let args = std::env::args().skip(1).collect::<Vec<_>>();
let helper_only = args.iter().any(|arg| arg == "--helper-only");
let options = parse_launch_options(args.iter());
Comment on lines +220 to +223
fn port_bind_forbidden(error: &std::io::Error) -> bool {
error.kind() == std::io::ErrorKind::PermissionDenied
|| matches!(error.raw_os_error(), Some(10013))
}
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