Skip to content
Merged
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
19 changes: 14 additions & 5 deletions libs/inspector_server/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
)
}
Expand Down
1 change: 1 addition & 0 deletions tests/node_compat/config.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading