-
Notifications
You must be signed in to change notification settings - Fork 8
fix: reduce logs on port already in use #150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughRefactored port allocation and forwarding in iOS device handling to use port ranges and constants instead of single ports, replaced fixed sleeps with configurable timeouts, extended AVC format support to iOS real devices while blocking on simulators, and added a port range finder utility function. Changes
Possibly related PRs
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
utils/port-manager.go (1)
24-31: Consolidate duplicate port-finding logic to reduce maintenance burden.The codebase has two identical implementations of the same port-finding logic:
FindAvailablePortInRangeinutils/port-manager.go(used indevices/simulator.go)findAvailablePortInRangeindevices/ios.go(used locally 4 times: lines 334, 384, 893, 906)The
devices/ios.gofile should use the exportedutils.FindAvailablePortInRangefunction instead of maintaining its own copy to avoid duplication and reduce maintenance overhead.
🧹 Nitpick comments (2)
devices/ios.go (2)
1000-1007: Duplicate ofutils.FindAvailablePortInRange.This local function duplicates the exported
FindAvailablePortInRangeinutils/port-manager.go. Consider removing this and usingutils.FindAvailablePortInRangeinstead for consistency and to avoid duplication.♻️ Proposed fix
Remove this function and update callers to use the utils version:
-// findAvailablePortInRange finds an available port in the specified range -func findAvailablePortInRange(start, end int) (int, error) { - for port := start; port <= end; port++ { - if utils.IsPortAvailable("localhost", port) { - return port, nil - } - } - return 0, fmt.Errorf("no available ports found in range %d-%d", start, end) -}Then update all callers (lines 334, 384, 893, 906) from
findAvailablePortInRange(...)toutils.FindAvailablePortInRange(...).
383-398: Removeif trueblock wrapper.The
if true {on line 383 is always true, making it dead conditional logic. This appears to be leftover from debugging or development. The block contents should remain, but the conditional wrapper should be removed.♻️ Proposed fix
- // assuming everything went well if we reached this point - if true { - portMjpeg, err := findAvailablePortInRange(portRangeStart, portRangeEnd) + // Set up MJPEG port forwarding + portMjpeg, err := findAvailablePortInRange(portRangeStart, portRangeEnd) ... - }
|
Closing, too many conflicts |
Summary by CodeRabbit
New Features
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.