Skip to content
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

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

Closed
weinand opened this issue Feb 24, 2019 · 0 comments
Closed

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

weinand opened this issue Feb 24, 2019 · 0 comments
Assignees
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality on-testplan
Milestone

Comments

@weinand
Copy link
Contributor

weinand commented Feb 24, 2019

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.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug Debug viewlet, configurations, breakpoints, adapter issues feature-request Request for new features or functionality on-testplan
Projects
None yet
Development

No branches or pull requests

1 participant