@@ -107,7 +107,7 @@ impl SyncContext {
107
107
}
108
108
109
109
#[ tracing:: instrument( skip( self ) ) ]
110
- pub ( crate ) async fn pull_one_frame ( & mut self , generation : u32 , frame_no : u32 ) -> Result < Bytes > {
110
+ pub ( crate ) async fn pull_one_frame ( & mut self , generation : u32 , frame_no : u32 ) -> Result < Option < Bytes > > {
111
111
let uri = format ! (
112
112
"{}/sync/{}/{}/{}" ,
113
113
self . sync_url,
@@ -116,9 +116,13 @@ impl SyncContext {
116
116
frame_no + 1
117
117
) ;
118
118
tracing:: debug!( "pulling frame" ) ;
119
- let frame = self . pull_with_retry ( uri, self . max_retries ) . await ?;
120
- self . durable_frame_num = frame_no;
121
- Ok ( frame)
119
+ match self . pull_with_retry ( uri, self . max_retries ) . await ? {
120
+ Some ( frame) => {
121
+ self . durable_frame_num = frame_no;
122
+ Ok ( Some ( frame) )
123
+ }
124
+ None => Ok ( None ) ,
125
+ }
122
126
}
123
127
124
128
#[ tracing:: instrument( skip( self , frame) ) ]
@@ -232,7 +236,7 @@ impl SyncContext {
232
236
}
233
237
}
234
238
235
- async fn pull_with_retry ( & self , uri : String , max_retries : usize ) -> Result < Bytes > {
239
+ async fn pull_with_retry ( & self , uri : String , max_retries : usize ) -> Result < Option < Bytes > > {
236
240
let mut nr_retries = 0 ;
237
241
loop {
238
242
let mut req = http:: Request :: builder ( ) . method ( "GET" ) . uri ( uri. clone ( ) ) ;
@@ -256,7 +260,10 @@ impl SyncContext {
256
260
let frame = hyper:: body:: to_bytes ( res. into_body ( ) )
257
261
. await
258
262
. map_err ( SyncError :: HttpBody ) ?;
259
- return Ok ( frame) ;
263
+ return Ok ( Some ( frame) ) ;
264
+ }
265
+ if res. status ( ) == StatusCode :: BAD_REQUEST {
266
+ return Ok ( None ) ;
260
267
}
261
268
// If we've retried too many times or the error is not a server error,
262
269
// return the error.
0 commit comments