File tree Expand file tree Collapse file tree 1 file changed +19
-6
lines changed
crates/worker/src/operations/heartbeat Expand file tree Collapse file tree 1 file changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -207,12 +207,25 @@ async fn send_heartbeat(
207207 . map_err ( |e| {
208208 log:: error!( "Request failed: {:?}" , e) ;
209209 HeartbeatError :: RequestFailed
210- } ) ?
211- . error_for_status ( )
212- . map_err ( |e| {
213- log:: error!( "Error response received: {:?}" , e) ;
214- HeartbeatError :: RequestFailed
215- } ) ?
210+ } ) ?;
211+
212+ let response = if response. status ( ) . is_success ( ) {
213+ response
214+ } else {
215+ let status = response. status ( ) ;
216+ let error_text = response
217+ . text ( )
218+ . await
219+ . unwrap_or_else ( |_| "Failed to read error response" . to_string ( ) ) ;
220+ log:: error!(
221+ "Error response received: status={}, body={}" ,
222+ status,
223+ error_text
224+ ) ;
225+ return Err ( HeartbeatError :: RequestFailed ) ;
226+ } ;
227+
228+ let response = response
216229 . json :: < ApiResponse < HeartbeatResponse > > ( )
217230 . await
218231 . map_err ( |e| {
You can’t perform that action at this time.
0 commit comments