Skip to content

Commit

Permalink
fix: add a max timeout for outgoing requests
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr committed Sep 10, 2024
1 parent 20cfa57 commit 89bbaac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion components/chainhook-sdk/src/chainhooks/bitcoin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use serde::{de, Deserialize, Deserializer};
use serde_json::Value as JsonValue;
use std::{
collections::{BTreeMap, HashMap, HashSet},
str::FromStr,
str::FromStr, time::Duration,
};

use reqwest::RequestBuilder;
Expand Down Expand Up @@ -766,6 +766,7 @@ pub fn handle_bitcoin_hook_action<'a>(
match &trigger.chainhook.action {
HookAction::HttpPost(http) => {
let client = Client::builder()
.timeout(Duration::from_secs(30))
.build()
.map_err(|e| format!("unable to build http client: {}", e.to_string()))?;
let host = format!("{}", http.url);
Expand Down
2 changes: 2 additions & 0 deletions components/chainhook-sdk/src/chainhooks/stacks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ use schemars::JsonSchema;
use serde_json::Value as JsonValue;
use std::collections::{BTreeMap, HashMap};
use std::io::Cursor;
use std::time::Duration;

use reqwest::RequestBuilder;

Expand Down Expand Up @@ -1337,6 +1338,7 @@ pub fn handle_stacks_hook_action<'a>(
match &trigger.chainhook.action {
HookAction::HttpPost(http) => {
let client = Client::builder()
.timeout(Duration::from_secs(30))
.build()
.map_err(|e| format!("unable to build http client: {}", e.to_string()))?;
let host = format!("{}", http.url);
Expand Down

0 comments on commit 89bbaac

Please sign in to comment.