@@ -12,9 +12,13 @@ use cli::Args;
1212use overpass:: { download_data, parse_response, process_elements} ;
1313use utils:: { get_file_size_human, log_error, log_info} ;
1414
15- fn serialize_json_pretty < T : serde:: Serialize > ( value : & T ) -> Result < Vec < u8 > > {
15+ /// Extra seconds to add to HTTP client timeout beyond the Overpass query timeout
16+ /// This provides buffer for network latency and response processing
17+ const HTTP_TIMEOUT_BUFFER_SECONDS : u64 = 1 ;
18+
19+ fn serialize_json_pretty < T : serde:: Serialize > ( value : & T , indent : & [ u8 ] ) -> Result < Vec < u8 > > {
20+ let formatter = serde_json:: ser:: PrettyFormatter :: with_indent ( indent) ;
1621 let mut output = Vec :: new ( ) ;
17- let formatter = serde_json:: ser:: PrettyFormatter :: with_indent ( b" " ) ;
1822 let mut serializer = serde_json:: Serializer :: with_formatter ( & mut output, formatter) ;
1923 value
2024 . serialize ( & mut serializer)
@@ -29,7 +33,7 @@ async fn main() -> Result<()> {
2933 // Build HTTP client
3034 let client = reqwest:: Client :: builder ( )
3135 . timeout ( std:: time:: Duration :: from_secs (
32- args. timeout_seconds as u64 + 30 ,
36+ args. timeout_seconds as u64 + HTTP_TIMEOUT_BUFFER_SECONDS ,
3337 ) )
3438 . build ( )
3539 . context ( "Failed to build HTTP client" ) ?;
@@ -74,7 +78,7 @@ async fn main() -> Result<()> {
7478 let processed = process_elements ( overpass_response. elements ) ?;
7579
7680 // Serialize to JSON with pretty formatting (1-space indentation)
77- let json_output = serialize_json_pretty ( & processed) ?;
81+ let json_output = serialize_json_pretty ( & processed, b" " ) ?;
7882
7983 // Compress with gzip
8084 let output_file = File :: create ( & args. outfile_compressed )
0 commit comments