diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b91da82..da95a25 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,9 +2,7 @@ name: 🧪 Test on: push: - branches: [main, master] pull_request: - branches: [main, master] jobs: test: diff --git a/rust/Cargo.lock b/rust/Cargo.lock index b18761c..8bf0e39 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -841,6 +841,12 @@ version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" +[[package]] +name = "rustls-pki-types" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79" + [[package]] name = "ryu" version = "1.0.20" @@ -1084,6 +1090,18 @@ dependencies = [ "syn", ] +[[package]] +name = "tokio-socks" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d4770b8024672c1101b3f6733eab95b18007dbe0847a8afe341fcf79e06043f" +dependencies = [ + "either", + "futures-util", + "thiserror", + "tokio", +] + [[package]] name = "tokio-util" version = "0.7.16" @@ -1215,6 +1233,15 @@ dependencies = [ "wit-bindgen", ] +[[package]] +name = "webpki-root-certs" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05d651ec480de84b762e7be71e6efa7461699c19d9e2c272c8d93455f567786e" +dependencies = [ + "rustls-pki-types", +] + [[package]] name = "winapi" version = "0.3.9" @@ -1354,9 +1381,11 @@ dependencies = [ "socket2", "tokio", "tokio-boring2", + "tokio-socks", "tower", "tower-http", "want", + "webpki-root-certs", "zstd", ] diff --git a/rust/Cargo.toml b/rust/Cargo.toml index d7596e9..dd2591e 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -9,7 +9,7 @@ crate-type = ["cdylib"] [dependencies] # HTTP client with browser impersonation -wreq = { version = "6.0.0-rc.20", default-features = false, features = ["cookies", "json"] } +wreq = { version = "6.0.0-rc.20", default-features = false, features = ["gzip", "deflate", "socks", "cookies", "json", "webpki-roots"] } wreq-util = "3.0.0-rc.1" # Neon for Node.js bindings diff --git a/rust/src/client.rs b/rust/src/client.rs index 27af937..b31752e 100644 --- a/rust/src/client.rs +++ b/rust/src/client.rs @@ -75,7 +75,7 @@ pub async fn make_request(options: RequestOptions) -> Result { let response = request .send() .await - .context("Failed to send request")?; + .with_context(|| format!("{} {}", method, options.url))?; // Extract response data let status = response.status().as_u16(); diff --git a/rust/src/lib.rs b/rust/src/lib.rs index bec49c4..f5e6611 100644 --- a/rust/src/lib.rs +++ b/rust/src/lib.rs @@ -220,7 +220,11 @@ fn request(mut cx: FunctionContext) -> JsResult { deferred.settle_with(&channel, move |mut cx| { match result { Ok(response) => response_to_js_object(&mut cx, response), - Err(e) => cx.throw_error(format!("Request failed: {}", e)), + Err(e) => { + // Format error with full chain for better debugging + let error_msg = format!("{:#}", e); + cx.throw_error(error_msg) + } } }); }); diff --git a/src/node-wreq.ts b/src/node-wreq.ts index c2ed0ee..52acd13 100644 --- a/src/node-wreq.ts +++ b/src/node-wreq.ts @@ -97,7 +97,7 @@ export async function request(options: RequestOptions): Promise { try { return await nativeBinding.request(options); } catch (error) { - throw new RequestError(`Request failed: ${error}`); + throw new RequestError(String(error)); } }