-
Notifications
You must be signed in to change notification settings - Fork 2.8k
feat(proxy): add debug-mode proxy routing #10467
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
Re-review complete. No new issues found in the latest commit.
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
4714d65 to
e47e8de
Compare
| // Setting a dispatcher on our `undici` dependency does NOT affect that internal fetch. | ||
| // To ensure Roo Code's `fetch()` calls are proxied, patch global fetch in debug mode. | ||
| if (!fetchPatched) { | ||
| globalThis.fetch = undiciFetch as unknown as typeof fetch |
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.
configureUndiciProxy() permanently patches globalThis.fetch when a proxy is configured in debug mode. Because this module is initialized unconditionally on activation, this can affect unrelated debug-only behaviors and makes it hard to reason about fetch semantics in extension-host tests/debug sessions. Suggest gating the patch behind an explicit internal flag or only patching where Roo Code actually uses fetch (for example, wrap/centralize fetch usage) so the behavior change is scoped.
Fix it with Roo Code or mention @roomote and request a fix.
| mockConfig.get.mockReturnValue("http://localhost:8080") | ||
| const context = createMockContext(vscode.ExtensionMode.Production) | ||
|
|
||
| expect(() => { |
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.
This test uses expect(() => { void initializeNetworkProxy(...) }) to check that no error is thrown. Since initializeNetworkProxy is async, errors may be missed. Convert the test to async and use await expect(initializeNetworkProxy(...)).resolves.not.toThrow() to properly catch async errors.
| loggingEnabled = config.isDebugMode || config.enabled || config.tlsInsecure | ||
| consoleLoggingEnabled = config.isDebugMode && !outputChannel | ||
|
|
||
| log(`Initializing network proxy module...`) |
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.
How much (if any) of this do you want to log when it is disabled?
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.
Added early-exit at the top of initializeNetworkProxy() so when debug mode is disabled, we skip all work including logging. Zero overhead in production.
jr
left a 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.
Can extensionContext.extensionMode ever change in process's lifespan? If not, we might want to stop early in initializeNetworkProxy and not do anything at all unless we're in debug mode?
Address review feedback from jr: - Check extensionMode at top of initializeNetworkProxy and return immediately if not in debug mode (extensionMode is immutable for process lifetime) - Remove verbose logging when proxy is disabled - Remove unnecessary typeof guard for onDidChangeConfiguration - Remove redundant trailing comment
|
Re: @jr's review about early exit when not in debug mode: Yes, // extensionMode is immutable for the process lifetime - exit early if not in debug mode.
// This avoids any overhead (listeners, logging, etc.) in production.
const isDebugMode = context.extensionMode === vscode.ExtensionMode.Development
if (!isDebugMode) {
return
}This ensures zero overhead (no listeners, no logging, nothing) in production builds. |
Summary
Closes #7042
Adds debug-mode proxy settings (
debugProxy.enabled,debugProxy.serverUrl,debugProxy.tlsInsecure) and initializes a debug-only global proxy/TLS bypass so extension network traffic can be routed through an intercepting proxy during F5 runs.Changes
debugProxy.enabledsetting to explicitly enable/disable proxy routingdebugProxy.serverUrlsetting with defaulthttp://127.0.0.1:8888debugProxy.tlsInsecuresetting to disable TLS verification for MITM proxy inspectionglobal-agentplus anundiciglobal dispatcher (and patchfetchin debug mode)global-agent/undiciare external in the extension bundleTesting
debugProxy.enabledin VS Code settingshttp://127.0.0.1:8888debugProxy.tlsInsecureImportant
Adds debug-mode proxy routing to the Roo Code extension, enabling network traffic to be routed through a proxy during development, with new settings, implementation in
networkProxy.ts, and comprehensive tests.debugProxy.enabled,debugProxy.serverUrl, anddebugProxy.tlsInsecuresettings inpackage.jsonfor proxy configuration.activate()inextension.tsto route network traffic through a proxy in debug mode.global-agentandundicito handle proxy routing and TLS settings.initializeNetworkProxy()innetworkProxy.tsto set up proxy based on settings.getProxyConfig(),isProxyEnabled(), andisDebugMode()functions innetworkProxy.ts.global-agentandundicifor proxy routing innetworkProxy.ts.networkProxy.spec.tsto verify proxy configuration and behavior.global-agentandvscodefor testing purposes.global-agentinglobal-agent.d.ts.package.nls.*.jsonfiles for new settings descriptions.This description was created by
for 82ccf6c. You can customize this summary. It will automatically update as commits are pushed.