From 379eedc05c1a841557d8f0a9c2cd33ec3362d607 Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Mon, 4 Jan 2021 12:19:23 +0100 Subject: [PATCH] Revert "fix(inspector): add back list endpoint (#8894)" (#8977) This reverts commit 1a2e7741c33490d2a91147966019853c6b1d6a48. --- Cargo.lock | 155 --------------------------------- cli/Cargo.toml | 1 - cli/tests/integration_tests.rs | 60 ------------- runtime/inspector.rs | 34 ++++---- 4 files changed, 15 insertions(+), 235 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 55f3172a3f..87994f6d9b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -307,22 +307,6 @@ dependencies = [ "proc-macro-hack", ] -[[package]] -name = "core-foundation" -version = "0.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" - [[package]] name = "cpuid-bool" version = "0.1.2" @@ -448,7 +432,6 @@ dependencies = [ "os_pipe", "percent-encoding", "regex", - "reqwest", "ring", "rustyline", "rustyline-derive", @@ -806,21 +789,6 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" -[[package]] -name = "foreign-types" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" -dependencies = [ - "foreign-types-shared", -] - -[[package]] -name = "foreign-types-shared" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" - [[package]] name = "form_urlencoded" version = "1.0.0" @@ -1164,19 +1132,6 @@ dependencies = [ "webpki", ] -[[package]] -name = "hyper-tls" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d979acc56dcb5b8dddba3917601745e877576475aa046df3226eabdecef78eed" -dependencies = [ - "bytes 0.5.6", - "hyper", - "native-tls", - "tokio 0.2.22", - "tokio-tls", -] - [[package]] name = "ident_case" version = "1.0.1" @@ -1549,24 +1504,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "native-tls" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8d96b2e1c8da3957d58100b09f102c6d9cfdfced01b7ec5a8974044bb09dbd4" -dependencies = [ - "lazy_static", - "libc", - "log", - "openssl", - "openssl-probe", - "openssl-sys", - "schannel", - "security-framework", - "security-framework-sys", - "tempfile", -] - [[package]] name = "net2" version = "0.2.35" @@ -1689,39 +1626,6 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" -[[package]] -name = "openssl" -version = "0.10.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038d43985d1ddca7a9900630d8cd031b56e4794eecc2e9ea39dd17aa04399a70" -dependencies = [ - "bitflags", - "cfg-if 1.0.0", - "foreign-types", - "lazy_static", - "libc", - "openssl-sys", -] - -[[package]] -name = "openssl-probe" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" - -[[package]] -name = "openssl-sys" -version = "0.9.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "921fc71883267538946025deffb622905ecad223c28efbfdef9bb59a0175f3e6" -dependencies = [ - "autocfg", - "cc", - "libc", - "pkg-config", - "vcpkg", -] - [[package]] name = "ordered-float" version = "1.1.0" @@ -1894,12 +1798,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "pkg-config" -version = "0.3.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" - [[package]] name = "pmutil" version = "0.5.3" @@ -2123,23 +2021,19 @@ dependencies = [ "http-body", "hyper", "hyper-rustls", - "hyper-tls", "ipnet", "js-sys", "lazy_static", "log", "mime", "mime_guess", - "native-tls", "percent-encoding", "pin-project-lite 0.1.7", "rustls", "serde", - "serde_json", "serde_urlencoded", "tokio 0.2.22", "tokio-rustls", - "tokio-tls", "url", "wasm-bindgen", "wasm-bindgen-futures", @@ -2250,16 +2144,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "schannel" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" -dependencies = [ - "lazy_static", - "winapi 0.3.9", -] - [[package]] name = "scoped-tls" version = "1.0.0" @@ -2282,29 +2166,6 @@ dependencies = [ "untrusted", ] -[[package]] -name = "security-framework" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1759c2e3c8580017a484a7ac56d3abc5a6c1feadf88db2f3633f12ae4268c69" -dependencies = [ - "bitflags", - "core-foundation", - "core-foundation-sys", - "libc", - "security-framework-sys", -] - -[[package]] -name = "security-framework-sys" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f99b9d5e26d2a71633cc4f2ebae7cc9f874044e0c351a27e17892d76dce5678b" -dependencies = [ - "core-foundation-sys", - "libc", -] - [[package]] name = "semver" version = "0.9.0" @@ -3040,16 +2901,6 @@ dependencies = [ "tokio 0.2.22", ] -[[package]] -name = "tokio-tls" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a70f4fcd7b3b24fb194f837560168208f669ca8cb70d0c4b862944452396343" -dependencies = [ - "native-tls", - "tokio 0.2.22", -] - [[package]] name = "tokio-tungstenite" version = "0.11.0" @@ -3254,12 +3105,6 @@ dependencies = [ "rand", ] -[[package]] -name = "vcpkg" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b00bca6106a5e23f3eee943593759b7fcddb00554332e856d990c893966879fb" - [[package]] name = "vec_map" version = "0.8.2" diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 0349491cb7..5b715ba9de 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -86,7 +86,6 @@ os_pipe = "0.9.2" test_util = { path = "../test_util" } tokio-tungstenite = "0.11.0" tower-test = "0.3.0" -reqwest = {version = "0.10.8", features = ["json"]} [target.'cfg(unix)'.dev-dependencies] exec = "0.3.1" # Used in test_raw_tty diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 2383db0dad..9400db4add 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -4345,66 +4345,6 @@ async fn inspector_runtime_evaluate_does_not_crash() { child.wait().unwrap(); } -#[tokio::test] -async fn inspector_json() { - let script = util::tests_path().join("inspector1.js"); - let mut child = util::deno_cmd() - .arg("run") - .arg(inspect_flag_with_unique_port("--inspect")) - .arg(script) - .stderr(std::process::Stdio::piped()) - .spawn() - .unwrap(); - - let stderr = child.stderr.as_mut().unwrap(); - let mut stderr_lines = - std::io::BufReader::new(stderr).lines().map(|r| r.unwrap()); - let ws_url = extract_ws_url_from_stderr(&mut stderr_lines); - let mut url = ws_url.clone(); - let _ = url.set_scheme("http"); - url.set_path("/json"); - let resp = reqwest::get(url).await.unwrap(); - assert_eq!(resp.status(), reqwest::StatusCode::OK); - let endpoint_list = resp - .json::>() - .await - .unwrap(); - let matching_endpoint = endpoint_list - .iter() - .find(|e| e["webSocketDebuggerUrl"] == ws_url.as_str()); - assert!(matching_endpoint.is_some()); -} - -#[tokio::test] -async fn inspector_json_list() { - let script = util::tests_path().join("inspector1.js"); - let mut child = util::deno_cmd() - .arg("run") - .arg(inspect_flag_with_unique_port("--inspect")) - .arg(script) - .stderr(std::process::Stdio::piped()) - .spawn() - .unwrap(); - - let stderr = child.stderr.as_mut().unwrap(); - let mut stderr_lines = - std::io::BufReader::new(stderr).lines().map(|r| r.unwrap()); - let ws_url = extract_ws_url_from_stderr(&mut stderr_lines); - let mut url = ws_url.clone(); - let _ = url.set_scheme("http"); - url.set_path("/json/list"); - let resp = reqwest::get(url).await.unwrap(); - assert_eq!(resp.status(), reqwest::StatusCode::OK); - let endpoint_list = resp - .json::>() - .await - .unwrap(); - let matching_endpoint = endpoint_list - .iter() - .find(|e| e["webSocketDebuggerUrl"] == ws_url.as_str()); - assert!(matching_endpoint.is_some()); -} - #[test] fn websocket() { let _g = util::http_server(); diff --git a/runtime/inspector.rs b/runtime/inspector.rs index befaaebeee..58df05c54a 100644 --- a/runtime/inspector.rs +++ b/runtime/inspector.rs @@ -182,21 +182,20 @@ fn handle_ws_request( .status(http::StatusCode::BAD_REQUEST) .body("Not a valid Websocket Request".into()), }); - if resp.is_ok() { - tokio::task::spawn_local(async move { - let upgraded = body.on_upgrade().await.unwrap(); - let websocket = tokio_tungstenite::WebSocketStream::from_raw_socket( - upgraded, - tungstenite::protocol::Role::Server, - None, - ) - .await; - let (proxy, pump) = create_websocket_proxy(websocket); + tokio::task::spawn_local(async move { + let upgraded = body.on_upgrade().await.unwrap(); + let websocket = tokio_tungstenite::WebSocketStream::from_raw_socket( + upgraded, + tungstenite::protocol::Role::Server, + None, + ) + .await; + let (proxy, pump) = create_websocket_proxy(websocket); + + let _ = new_websocket_tx.unbounded_send(proxy); + pump.await; + }); - let _ = new_websocket_tx.unbounded_send(proxy); - pump.await; - }); - } resp } else { http::Response::builder() @@ -276,14 +275,11 @@ async fn server( (&http::Method::GET, path) if path.starts_with("/ws/") => { handle_ws_request(req, inspector_map.clone()) } - (&http::Method::GET, "/json/version") => { - handle_json_version_request(json_version_response.clone()) - } (&http::Method::GET, "/json") => { handle_json_request(inspector_map.clone()) } - (&http::Method::GET, "/json/list") => { - handle_json_request(inspector_map.clone()) + (&http::Method::GET, "/json/version") => { + handle_json_version_request(json_version_response.clone()) } _ => http::Response::builder() .status(http::StatusCode::NOT_FOUND)