Skip to content

Commit

Permalink
Refactors InspectorProxy to compare pathname portion of url passed in… (
Browse files Browse the repository at this point in the history
facebook#41005)

Summary:
… request to local pathname comparator variables to fix issue with other rightward elements of url such as query or fragment entering the comparison and causing 404 errors for key debugging routes.

A change in Chromium appended the query "?for_tabs" to the /json/list request made by Chrome DevTools to find remote debugger targets.

The current comparison in InspectorProxy.js compares the entire node IncomingMessage url field to the local pathname constants. The issue arises as url can also contain the query and fragment portions so the original comparison of "/json/list" === "/json/list" which resolved as true would become "/json/list?for_tabs" === "/json/list" and evaluate to false ultimately resulting in a 404 for the request.

In summary, all these changes/issues caused remote debugging of Hermes code in React Native apps to become unavailable, greatly impacting developer experience.

## Changelog:

[GENERAL] [FIXED] JS Debugging: Fix inspector-proxy to allow for DevTools requests with query strings

Pull Request resolved: facebook#41005

Reviewed By: NickGerleman

Differential Revision: D50342265

Pulled By: robhogan

fbshipit-source-id: a65f2908f0bea9fc15e1e3e4e6d31a3b9598e81f
  • Loading branch information
116-7 authored and facebook-github-bot committed Oct 17, 2023
1 parent fbc28fa commit ab81c16
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/dev-middleware/src/inspector-proxy/InspectorProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@ export default class InspectorProxy implements InspectorProxyQueries {
response: ServerResponse,
next: (?Error) => mixed,
) {
const pathname = url.parse(request.url).pathname;
if (
request.url === PAGES_LIST_JSON_URL ||
request.url === PAGES_LIST_JSON_URL_2
pathname === PAGES_LIST_JSON_URL ||
pathname === PAGES_LIST_JSON_URL_2
) {
this._sendJsonResponse(response, this.getPageDescriptions());
} else if (request.url === PAGES_LIST_JSON_VERSION_URL) {
} else if (pathname === PAGES_LIST_JSON_VERSION_URL) {
this._sendJsonResponse(response, {
Browser: 'Mobile JavaScript',
'Protocol-Version': '1.1',
Expand Down

0 comments on commit ab81c16

Please sign in to comment.