Skip to content

Support a "debug target ready" hook for launch configs #69311

Closed
@weinand

Description

@weinand

The discussion of microsoft/debug-adapter-protocol#23 came to the conclusion not to extend the Debug Adapter Protocol, but to implement a new VS Code feature instead.

This feature makes it possible to add the following structured property serverReadyAction to any launch config:

"serverReadyAction": {
    "action": "openExternally"
}

The feature looks for patterns of the form "listening on port 3000" or "Now listening on: https://localhost:5001" in the debug console output. If the pattern is found it extracts from it a port number or a URI (if only a port number is given, it is converted to a URI of the form "http://localhost:").

Then it opens the URI outside of VS Code ("externally") with the standard application configured for the URI's scheme.

Alternatively the action can be set to debugWithChrome. In this case VS Code starts a Chrome debug session for the URI (this requires that the "Debugger for Chrome" is installed).

Here are all supported properties and their default values:

"serverReadyAction": {
    "action": "openExternally",
    "pattern": "listening on.* (https?://\\S+|[0-9]+)",
    "uriFormat": "http://localhost:%s",
    "webRoot": "${workspaceFolder}",
}

In order for VS Code to locate and extract the port or URI in the pattern, that part of the pattern must be enclosed in parenthesis (aka "capture group"). If the pattern requires additional parenthesis, they must be marked as "non capturing" through the syntax: (?:pattern).

Please note:
In the preview release of the feature...

  • the pattern is only matched in the debug console. So the feature doesn't yet work if the debug target is launched in the integrated terminal (and it will never work in external terminals).
  • the feature does not warn if debugWithChrome is configured and the "Debugger for Chrome" is not installed (but a correct error message is shown).
  • it is not yet possible to use other browser based debuggers.

Metadata

Metadata

Assignees

Labels

debugDebug viewlet, configurations, breakpoints, adapter issuesfeature-requestRequest for new features or functionalityon-testplan

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions