diff --git a/libs/inspector_server/lib.rs b/libs/inspector_server/lib.rs index 77750a67a44d94..26d28a1a711512 100644 --- a/libs/inspector_server/lib.rs +++ b/libs/inspector_server/lib.rs @@ -258,10 +258,13 @@ fn handle_ws_request( let (parts, body) = req.into_parts(); let req = http::Request::from_parts(parts, ()); - let maybe_uuid = req - .uri() - .path() + // Accept both /UUID (Node.js-compatible format) and /ws/UUID (legacy + // format) so existing clients keep working while new ones can use the + // shorter Node.js-style URL. + let path = req.uri().path(); + let maybe_uuid = path .strip_prefix("/ws/") + .or_else(|| path.strip_prefix('/')) .and_then(|s| Uuid::parse_str(s).ok()); let Some(uuid) = maybe_uuid else { @@ -581,6 +584,12 @@ async fn server( (&http::Method::GET, "/json/list") if publish_uid.http => { handle_json_request(Rc::clone(&inspector_map), host) } + // Node.js-compatible "/UUID" path for the WebSocket session. + (&http::Method::GET, path) + if Uuid::parse_str(path.trim_start_matches('/')).is_ok() => + { + handle_ws_request(req, Rc::clone(&inspector_map)) + } _ => http::Response::builder() .status(http::StatusCode::NOT_FOUND) .body(Box::new(http_body_util::Full::new(Bytes::from( @@ -750,12 +759,12 @@ impl InspectorInfo { } pub fn get_websocket_debugger_url(&self, host: &str) -> String { - format!("ws://{}/ws/{}", host, &self.uuid) + format!("ws://{}/{}", host, &self.uuid) } fn get_frontend_url(&self, host: &str) -> String { format!( - "devtools://devtools/bundled/js_app.html?ws={}/ws/{}&experiments=true&v8only=true", + "devtools://devtools/bundled/js_app.html?ws={}/{}&experiments=true&v8only=true", host, &self.uuid ) } diff --git a/tests/node_compat/config.jsonc b/tests/node_compat/config.jsonc index 5da0faa75616b6..5152baf3c02dd9 100644 --- a/tests/node_compat/config.jsonc +++ b/tests/node_compat/config.jsonc @@ -1853,6 +1853,7 @@ // "parallel/test-inspect-address-in-use.js": {}, // "parallel/test-inspector-inspect-brk-node.js": {}, // "parallel/test-inspector-invalid-args.js": {}, + "parallel/test-inspector-invalid-protocol.js": {}, "parallel/test-inspector-close-worker.js": {}, // TODO(bartlomieju): times out