@@ -143,7 +143,7 @@ def sync(self) -> Iterable[Update]:
143143 if action .error is None :
144144 continue
145145
146- (should_continue , update ) = self ._handle_error (action .error )
146+ (update , should_continue ) = self ._handle_error (action .error )
147147 if update is not None :
148148 yield update
149149
@@ -165,7 +165,7 @@ def sync(self) -> Iterable[Update]:
165165 # TODO(sdk-1409)
166166 # self._sse.interrupt()
167167
168- (should_continue , update ) = self ._handle_error (e )
168+ (update , should_continue ) = self ._handle_error (e )
169169 if update is not None :
170170 yield update
171171 if not should_continue :
@@ -294,8 +294,16 @@ def _process_message(
294294 log .info ("Unexpected event found in stream: %s" , msg .event )
295295 return None
296296
297- # Returns true to continue, false to stop
298- def _handle_error (self , error : Exception ) -> Tuple [bool , Optional [Update ]]:
297+ def _handle_error (self , error : Exception ) -> Tuple [Optional [Update ], bool ]:
298+ """
299+ This method handles errors that occur during the streaming process.
300+
301+ It may return an update indicating the error state, and a boolean
302+ indicating whether the synchronizer should continue retrying the connection.
303+
304+ If an update is provided, it should be forward upstream, regardless of
305+ whether or not we are going to retry this failure.
306+ """
299307 # if not self._running:
300308 # return (False, None) # don't retry if we've been deliberately stopped
301309
@@ -312,7 +320,7 @@ def _handle_error(self, error: Exception) -> Tuple[bool, Optional[Update]]:
312320 revert_to_fdv1 = False ,
313321 environment_id = None , # TODO(sdk-1410)
314322 )
315- return (True , update )
323+ return (update , True )
316324
317325 if isinstance (error , HTTPStatusError ):
318326 error_info = DataSourceErrorInfo (
@@ -345,10 +353,10 @@ def _handle_error(self, error: Exception) -> Tuple[bool, Optional[Update]]:
345353 # self._ready.set() # if client is initializing, make it stop waiting; has no effect if already inited
346354 # self.__stop_with_error_info(error_info)
347355 # self.stop()
348- return (False , update )
356+ return (update , False )
349357
350358 log .warning (http_error_message_result )
351- return (True , update )
359+ return (update , True )
352360
353361 log .warning ("Unexpected error on stream connection: %s, will retry" , error )
354362
@@ -363,7 +371,7 @@ def _handle_error(self, error: Exception) -> Tuple[bool, Optional[Update]]:
363371 # no stacktrace here because, for a typical connection error, it'll
364372 # just be a lengthy tour of urllib3 internals
365373
366- return (True , update )
374+ return (update , True )
367375
368376 # magic methods for "with" statement (used in testing)
369377 def __enter__ (self ):
0 commit comments