Allow multiple Dev Proxy instances when asSystemProxy is false#1589
Open
Allow multiple Dev Proxy instances when asSystemProxy is false#1589
Conversation
When asSystemProxy is false, the single-instance check is skipped so multiple Dev Proxy instances can run simultaneously. The AsSystemProxy value is now stored in the state file so the detached mode launch check can determine if the existing instance is acting as the system proxy. Closes #1586 Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix issue with running multiple instances of Dev Proxy
Allow multiple Dev Proxy instances when asSystemProxy is false
Mar 5, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Updates detached-mode instance detection so Dev Proxy only blocks starting a new detached instance when an existing detached instance owns the system proxy, enabling coexistence when asSystemProxy is false.
Changes:
- Add
asSystemProxyto the detached instance state file (defaulting totruefor backward compatibility). - Parse
--as-system-proxyearly viaDevProxyConfigOptionsso it can be persisted into detached state. - Change detached startup logic to gate the “already running” check on
existingState.AsSystemProxy.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| DevProxy/State/ProxyInstanceState.cs | Adds AsSystemProxy to persisted detached state (back-compat default true). |
| DevProxy/Program.cs | Gates detached single-instance check on existingState.AsSystemProxy and persists asSystemProxy into state. |
| DevProxy/Commands/DevProxyConfigOptions.cs | Adds early parsing access for --as-system-proxy before full config load. |
You can also share your feedback on Copilot code review. Take the survey.
Collaborator
|
@copilot apply changes based on the comments in this thread |
Each detached instance now stores its state in a separate file keyed by PID (e.g. state-1234.json) instead of a single shared state.json. This ensures that: - Multiple non-system-proxy instances don't overwrite each other's state - Deleting state on exit only removes the current instance's file - devproxy stop/status/logs still work by preferring the system-proxy instance, then falling back to the most recently started one - Legacy state.json files are still read for backward compatibility StopCommand now passes the specific PID when deleting state to avoid accidentally removing another instance's state file. Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Co-authored-by: waldekmastykarz <11164679+waldekmastykarz@users.noreply.github.com>
Contributor
Author
Applied the review feedback in
|
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.
The detached mode single-instance check unconditionally blocks new instances regardless of
asSystemProxy. WhenasSystemProxyisfalse, instances don't conflict over system proxy registration and should be allowed to coexist.Changes
ProxyInstanceState— TrackasSystemProxyin the state file (defaults totruefor backward compat with existing state files)DevProxyConfigOptions— Register--as-system-proxyfor early CLI arg parsing before full config loadStateManager— Switch from a single sharedstate.jsonto per-instance state files (state-{pid}.json) to avoid cross-instance interference. Each instance writes/deletes only its own file.LoadStateAsync()prefers the system-proxy instance, then falls back to the most recently started one.FindSystemProxyInstanceAsync()scans all state files to reliably detect a running system-proxy instance. Legacystate.jsonis still read for backward compatibility.Program.cs— UseFindSystemProxyInstanceAsync()for the system-proxy conflict check; useLoadStateByPidAsync(process.Id)in the detached startup wait loop to find the specific child process; resolveasSystemProxyfrom CLI args → config file fallback and persist to stateStopCommand— Pass the specificstate.PidtoDeleteStateAsyncto avoid accidentally removing another instance's state fileOriginal prompt
asSystemProxyis false allow running multiple instances #1586💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.