Fix port conflict error message and cleanup on failure#40102
Open
beena352 wants to merge 8 commits intomicrosoft:feature/wsl-for-appsfrom
Open
Fix port conflict error message and cleanup on failure#40102beena352 wants to merge 8 commits intomicrosoft:feature/wsl-for-appsfrom
beena352 wants to merge 8 commits intomicrosoft:feature/wsl-for-appsfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Updates WSLC container startup to surface a correct “port already in use” error to users (instead of a misleading “distribution already exists” message) and ensures containers are cleaned up when Start() fails during wslc container run.
Changes:
- Switch port-conflict handling to
THROW_HR_WITH_USER_ERROR(_IF)so a user-facing message can be surfaced. - Add error translation around
MapPort()to try to convert port-conflict failures into a clearer user error. - Fix
wslc container runfailure cleanup by only disabling auto-delete after a successfulStart().
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/windows/wslcsession/WSLCContainer.cpp | Improves port-conflict error surfacing during port allocation/mapping for container open/start. |
| src/windows/wslc/services/ContainerService.cpp | Ensures container run doesn’t leak containers when Start() fails by keeping auto-delete enabled until after a successful start. |
…ttps://github.com/beena352/WSL into user/beenachauhan/fix-port-conflict-error-message
Member
|
Hey @beena352 👋 — Following up on this draft PR. There are 2 unresolved review threads:
Is this change still being worked on? Addressing those review items would help move this forward. |
OneBlue
reviewed
Apr 8, 2026
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.
Summary of the Pull Request
Fix port conflict error message in wslc container run. When starting a container on a port that is already in use, users previously saw the misleading message “A distribution with the supplied name already exists.” With this fix, the correct error is shown (for example, “Port 8080 is already in use, cannot start container ”). Also clean up the container left behind when Start() fails.
PR Checklist
Detailed Description of the Pull Request / Additional comments
Validation Steps Performed