Skip to content

Update devtoolsFrontendUrl value in target list #39122

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)}`;
}