fix: tolerate Windows reserved launcher ports#1293
Open
577fkj wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
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)) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix Codex++ startup failure caused by a Windows-reserved port.