[Blazor] allow inspectorUri in Chrome launch configurations
To debug Blazor apps, we need to use its CDP-speaking proxy service, which runs at a separate address than whatever browser we launch. Therefore, the inspector uri needs to be configurable. We suggest adding an additional option to the Chrome launch configuration:
export interface IChromeLaunchConfiguration {
/**
* WebSocket (`ws://`) address of the inspector. It's a template string that
* interpolates keys in `{curlyBraces}`. Available keys are:
*
* - `url.*` is the parsed address of the running application. For instance,
* `{url.port}`, `{url.hostname}`
* - `port` is the debug port that Chrome is listening on.
* - `browserInspectUri` is the inspector URI on the launched browser
* - `wsProtocol` is the hinted websocket protocol. This is set to `wss` if
* the original URL is `https`, or `ws` otherwise.
*/
inspectUri?: string;
Upon launch, if we see that the inspectUri is provided, we will launch chrome with a --remote-debugging-port (instead of a pipe), render that string, then create a WebSocket connection to it. If the connection fails, we will immediately abort the launch with an appropriate error.
const templateString = (input, replacement) =>
input.replace(
/{(.*?)}/g,
(match, key) => replacement.hasOwnProperty(key) ? replacement[key] : match,
);
One convenient thing about this approach over the original one (below) is that additional options can be passed to the proxy without needing changes in VS code. For example, if we wanted to pass whether the user has enabled telemetry as a parameter, that could be done without a js-debug change. It may also be used in case other X-to-JavaScript/WASM frameworks/tools do similar things in the future, as they may have their own setups.
Open question: this partially duplicates some options in the Chrome attach scenario. Should we try to unify these options?
Original proposal (email)
-
VS sees that
launchSettings.jsoncontains a value fordebugEndpoint. Example:"debugEndpoint": "/_framework/debug/ws-proxy"This causes it not to connect the JS debugger todirectly as it does today, but instead follows this alternate flow. -
VS defines
= ws(s)://<applicationUrl><debugEndpoint>?browser=<browserCdpEndpoint>Example:wss://localhost:5001/_framework/debug/ws-proxy?browser=ws://127.0.0.1:36775/devtools/browser/a292f96c-7332-4ce8-82a9-7411f3bd280a -
VS connects the JS debugger to
cc @digeff @SteveSandersonMS @roblourens
As an example if we launch with:
{ url: "http://localhost:5001/",
inspectUri: "{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser=" }
We'd end up connecting to something like:
wss://localhost:5001/_framework/debug/ws-proxy?browser=ws://127.0.0.1:36775/devtools/browser/a292f96c-7332-4ce8-82a9-7411f3bd280a
correct?
That would be "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}". Left out browserInspectUri in the original issue, updated it now.