Debug extension host without requiring a restart - #326534
Open
Haras (ArasHuseyin) wants to merge 2 commits into
Open
Debug extension host without requiring a restart#326534Haras (ArasHuseyin) wants to merge 2 commits into
Haras (ArasHuseyin) wants to merge 2 commits into
Conversation
The shared getExtensionHostPort helper called getInspectPorts with tryEnableInspector=false, so the Debug Extension Host actions always prompted for a restart. The profiling and dev-tools paths already pass true, which enables the inspector on the running extension host via process._debugProcess(pid). Align the debug action with them; the restart prompt remains as a fallback when the inspector cannot be enabled on the fly. Fixes microsoft#85422
Comment on lines
+40
to
+43
| // Try to enable the inspector on the already running extension host (same as profiling and the | ||
| // dev tools action do). This avoids forcing a restart just to debug extensions; the restart | ||
| // prompt below is only used as a fallback when the inspector cannot be enabled on the fly. | ||
| const inspectPorts = await extensionService.getInspectPorts(ExtensionHostKind.LocalProcess, true); |
Author
|
reduced the inline comment to a single line as suggested (3483d82). It now only notes the non-obvious intent (enabling the inspector on the running host to avoid a restart, matching the profiling path). |
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.
Fixes #85422
Problem
Clicking Debug Extension Host In New Window (and Debug Extension Host and Renderer In New Window) always prompts for a restart, even when the extension host is already running. This defeats the main use case of the feature — attaching a debugger to a running extension host to investigate an issue that is happening right now.
Cause
Both actions go through the shared
getExtensionHostPorthelper, which called:With
tryEnableInspector = false, the extension host manager never callsenableInspectPort(), so when the host was not started with--inspect-extensionsthere are no inspect ports and the code falls through to the restart prompt.The profiling path (
ExtensionHostProfileService.startProfiling) and the dev-tools path (DebugExtensionHostInDevToolsAction) already passtrue, which enables the inspector on the running extension host via node'sprocess._debugProcess(pid)(UtilityProcess.enableInspectPort) — no restart required. This matches the approach suggested by Andre Weinand (@weinand) and Johannes Rieken (@jrieken) in the issue, and explains Connor Peet (@connor4312)'s observation that profiling works without a restart while debugging does not.Fix
Pass
tryEnableInspector = truein the shared helper so the debug actions first try to enable the inspector on the running host, exactly like profiling. The restart prompt is kept as a fallback for the case where the inspector cannot be enabled on the fly (e.g._debugProcessunavailable or the host is not running).Notes
--inspect-extensions:enableInspectPort()short-circuits when an inspect listener already exists.