fix: skip proxy-only plugin initialization for CLI subcommands#1724
Draft
waldekmastykarz wants to merge 2 commits into
Draft
fix: skip proxy-only plugin initialization for CLI subcommands#1724waldekmastykarz wants to merge 2 commits into
waldekmastykarz wants to merge 2 commits into
Conversation
Add IsProxyCommand property to InitArgs so plugins can conditionally skip initialization that is only relevant for proxy operation (e.g., opening browsers, starting telemetry listeners) when running CLI subcommands like 'devproxy jwt create'. Update DevToolsPlugin and OpenAITelemetryPlugin to check this flag before performing their proxy-only initialization. Closes dotnet#1722 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses #1722 by adding an IsProxyCommand flag to plugin initialization so plugins can skip proxy-only initialization (eg. launching a browser / starting telemetry exporters) when Dev Proxy is invoked via CLI subcommands (eg. devproxy jwt create) rather than actually running the proxy.
Changes:
- Added
InitArgs.IsProxyCommand(defaulting totruefor compatibility) to let plugins know whether the proxy is being started. - Passed an
IsProxyCommandvalue when initializing plugins from the host. - Updated
DevToolsPluginandOpenAITelemetryPluginto return early whenIsProxyCommandisfalse.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| DevProxy.Abstractions/Proxy/ProxyEvents.cs | Adds IsProxyCommand to InitArgs with XML documentation and a default value. |
| DevProxy/Plugins/PluginServiceExtensions.cs | Passes IsProxyCommand into InitializeAsync when constructing plugins. |
| DevProxy.Plugins/Inspection/DevToolsPlugin.cs | Skips browser/inspector initialization when not running the proxy command. |
| DevProxy.Plugins/Inspection/OpenAITelemetryPlugin.cs | Skips telemetry/exporter initialization when not running the proxy command. |
Collaborator
Author
|
The build failure is pre-existing on |
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
Fixes #1722
When running CLI subcommands (e.g.,
devproxy jwt create), plugins likeDevToolsPluginwould still fully initialize — opening a browser window. This PR adds anIsProxyCommandproperty toInitArgsso plugins can skip initialization that is only relevant when the proxy is actually running.Changes
DevProxy.Abstractions/Proxy/ProxyEvents.cs— AddedIsProxyCommandtoInitArgs(defaults totruefor backwards compatibility)DevProxy/Plugins/PluginServiceExtensions.cs— PassesDevProxyCommand.IsRootCommandwhen constructingInitArgsDevProxy.Plugins/Inspection/DevToolsPlugin.cs— Skips browser initialization when not the proxy commandDevProxy.Plugins/Inspection/OpenAITelemetryPlugin.cs— Skips OTLP exporter/file watcher initialization when not the proxy commandBackwards compatibility
IsProxyCommanddefaults totrue, so existing external plugins continue to work unchanged.