Skip to content

Commit

Permalink
Update devtoolsFrontendUrl value in target list (facebook#39122)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#39122

Updates the `devtoolsFrontendUrl` value returned in the `/json/list` endpoint, to match the fixed DevTools frontend revision we set for `/open-debugger` — which now uses this as the source of truth.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D48561005

fbshipit-source-id: 7916c7d24917dd5bb5abde5668c922a015f1f631
  • Loading branch information
huntie authored and facebook-github-bot committed Aug 23, 2023
1 parent 97efa25 commit 1bd5d6d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
9 changes: 4 additions & 5 deletions packages/dev-middleware/src/inspector-proxy/InspectorProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import type {
import type {EventReporter} from '../types/EventReporter';
import type {IncomingMessage, ServerResponse} from 'http';

import Device from './Device';
import url from 'url';
import WS from 'ws';
import getDevToolsFrontendUrl from '../utils/getDevToolsFrontendUrl';
import Device from './Device';

const debug = require('debug')('Metro:InspectorProxy');

Expand Down Expand Up @@ -114,15 +115,13 @@ export default class InspectorProxy {
): PageDescription {
const debuggerUrl = `${this._serverBaseUrl}${WS_DEBUGGER_URL}?device=${deviceId}&page=${page.id}`;
const webSocketDebuggerUrl = 'ws://' + debuggerUrl;
const devtoolsFrontendUrl =
'devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws=' +
encodeURIComponent(debuggerUrl);

return {
id: `${deviceId}-${page.id}`,
description: page.app,
title: page.title,
faviconUrl: 'https://reactjs.org/favicon.ico',
devtoolsFrontendUrl,
devtoolsFrontendUrl: getDevToolsFrontendUrl(webSocketDebuggerUrl),
type: 'node',
webSocketDebuggerUrl,
vm: page.vm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import type {Logger} from '../types/Logger';

import url from 'url';
import getDevServerUrl from '../utils/getDevServerUrl';
import launchChromeDevTools from '../utils/launchChromeDevTools';
import launchDebuggerAppWindow from '../utils/launchDebuggerAppWindow';
import queryInspectorTargets from '../utils/queryInspectorTargets';

const debuggerInstances = new Map<string, LaunchedChrome>();
Expand Down Expand Up @@ -81,7 +81,10 @@ export default function openDebuggerMiddleware({
debuggerInstances.get(appId)?.kill();
debuggerInstances.set(
appId,
await launchChromeDevTools(target.webSocketDebuggerUrl),
await launchDebuggerAppWindow(
target.devtoolsFrontendUrl,
'open-debugger',
),
);
res.end();
eventReporter?.logEvent({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
* @oncall react_native
*/

import type {LaunchedChrome} from 'chrome-launcher';

import launchDebuggerAppWindow from './launchDebuggerAppWindow';

/**
* The Chrome DevTools frontend revision to use. This should be set to the
* latest version known to be compatible with Hermes.
Expand All @@ -23,16 +19,13 @@ import launchDebuggerAppWindow from './launchDebuggerAppWindow';
const DEVTOOLS_FRONTEND_REV = 'd9568d04d7dd79269c5a655d7ada69650c5a8336'; // Chrome 100.0.4896.75

/**
* Attempt to launch Chrome DevTools on the host machine for a given CDP target.
* Construct the URL to Chrome DevTools connected to a given debugger target.
*/
export default async function launchChromeDevTools(
export default function getDevToolsFrontendUrl(
webSocketDebuggerUrl: string,
): Promise<LaunchedChrome> {
): string {
const urlBase = `https://chrome-devtools-frontend.appspot.com/serve_rev/@${DEVTOOLS_FRONTEND_REV}/devtools_app.html`;
const ws = webSocketDebuggerUrl.replace(/^ws:\/\//, '');

return launchDebuggerAppWindow(
`${urlBase}?panel=console&ws=${encodeURIComponent(ws)}`,
'open-debugger',
);
return `${urlBase}?panel=console&ws=${encodeURIComponent(ws)}`;
}

0 comments on commit 1bd5d6d

Please sign in to comment.