:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(batch-exports): Handle invalid state error (#67080)
Tomás Farías Santanab0822b7bc8ff
diff --git a/products/batch_exports/backend/temporal/destinations/bigquery_batch_export.py b/products/batch_exports/backend/temporal/destinations/bigquery_batch_export.pyindex e81c5f41c504..3879e9a8980d 100644--- a/products/batch_exports/backend/temporal/destinations/bigquery_batch_export.py+++ b/products/batch_exports/backend/temporal/destinations/bigquery_batch_export.py@@ -1251,7 +1251,10 @@ class BigQueryStorageConsumer(Consumer):if resp.error.code in _RETRYABLE_CODES and attempt < max_attempts:backoff = min(2**attempt, 32)self.logger.warning(- "Storage stream transient error encountered", attempt=attempt, backoff=backoff+ "Storage stream response error",+ attempt=attempt,+ backoff=backoff,+ error_code=resp.error.code,)await self.close_stream()@@ -1263,10 +1266,18 @@ class BigQueryStorageConsumer(Consumer):return resp- except grpc.aio.AioRpcError as exc:- if exc.code() in _RETRYABLE_STATUS and attempt < max_attempts:+ except (grpc.aio.AioRpcError, asyncio.InvalidStateError) as exc:+ if (+ isinstance(exc, asyncio.InvalidStateError) or exc.code() in _RETRYABLE_STATUS+ ) and attempt < max_attempts:backoff = min(2**attempt, 32)- self.logger.warning("Storage stream transient error encountered", attempt=attempt, backoff=backoff)+ self.logger.warning(+ "Storage stream transient error encountered",+ attempt=attempt,+ backoff=backoff,+ exc_info=True,+ error_code=exc.code() if isinstance(exc, grpc.aio.AioRpcError) else None,+ )await self.close_stream()await asyncio.sleep(backoff)