Skip to content

Commit ab81c16

Browse files
116-7facebook-github-bot
authored andcommitted
Refactors InspectorProxy to compare pathname portion of url passed in… (#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: #41005 Reviewed By: NickGerleman Differential Revision: D50342265 Pulled By: robhogan fbshipit-source-id: a65f2908f0bea9fc15e1e3e4e6d31a3b9598e81f
1 parent fbc28fa commit ab81c16

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/dev-middleware/src/inspector-proxy/InspectorProxy.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,13 @@ export default class InspectorProxy implements InspectorProxyQueries {
9494
response: ServerResponse,
9595
next: (?Error) => mixed,
9696
) {
97+
const pathname = url.parse(request.url).pathname;
9798
if (
98-
request.url === PAGES_LIST_JSON_URL ||
99-
request.url === PAGES_LIST_JSON_URL_2
99+
pathname === PAGES_LIST_JSON_URL ||
100+
pathname === PAGES_LIST_JSON_URL_2
100101
) {
101102
this._sendJsonResponse(response, this.getPageDescriptions());
102-
} else if (request.url === PAGES_LIST_JSON_VERSION_URL) {
103+
} else if (pathname === PAGES_LIST_JSON_VERSION_URL) {
103104
this._sendJsonResponse(response, {
104105
Browser: 'Mobile JavaScript',
105106
'Protocol-Version': '1.1',

0 commit comments

Comments
 (0)