: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(temporalio): ride out transport-cancellation RPC errors (#81784)
Tom Owersde7c52113397
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/temporalio/temporalio.py b/products/warehouse_sources/backend/temporal/data_imports/sources/temporalio/temporalio.pyindex 0f3f6f4328a5..6118b4411a07 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/temporalio/temporalio.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/temporalio/temporalio.py@@ -81,7 +81,12 @@ _RETRYABLE_RPC_STATUSES = frozenset(# single read (ListWorkflowExecutions / GetWorkflowExecutionHistory), not the server rejecting the# request. It's the client-side analog of the DEADLINE_EXCEEDED case above, so ride it out too.# Match the phrase rather than the whole CANCELLED status so a genuine cancellation still surfaces.-_RETRYABLE_RPC_MESSAGES = ("h2 protocol error", "Timeout expired")+#+# tonic also surfaces status CANCELLED with the message "operation was canceled" when the+# underlying transport connection is closed mid-request (a known upstream pattern, e.g.+# temporalio/sdk-core#807) — another connection blip, not an intentional cancellation. Match the+# phrase, not the whole status, for the same reason as above.+_RETRYABLE_RPC_MESSAGES = ("h2 protocol error", "Timeout expired", "operation was canceled")def _is_retryable_rpc_error(error: RPCError) -> bool:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/temporalio/test_temporalio.py b/products/warehouse_sources/backend/temporal/data_imports/sources/temporalio/test_temporalio.pyindex 0e62d1261d96..bfa521daa952 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/temporalio/test_temporalio.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/temporalio/test_temporalio.py@@ -124,6 +124,9 @@ class TestTransientRPCRetry:# tonic cancels a call that outruns the client's RPC deadline with status CANCELLED and# message "Timeout expired" — a client-side timeout that must be ridden out, not raised.("Timeout expired", RPCStatusCode.CANCELLED),+ # A transport connection closed mid-request also surfaces as CANCELLED, with message+ # "operation was canceled" — a connection blip, not a real cancellation.+ ("operation was canceled", RPCStatusCode.CANCELLED),# A DNS resolution blip surfaces as UNAVAILABLE — a connection-level failure that must# be ridden out rather than failing the whole import activity.("dns error", RPCStatusCode.UNAVAILABLE),@@ -177,7 +180,8 @@ class TestTransientRPCRetry:("workflow execution not found for", RPCStatusCode.NOT_FOUND),# UNKNOWN alone must not be retried — only UNKNOWN carrying a transport signature is.("internal server error", RPCStatusCode.UNKNOWN),- # CANCELLED alone must not be retried — only the "Timeout expired" phrase qualifies.+ # CANCELLED alone must not be retried — only the "Timeout expired" and "operation was+ # canceled" phrases qualify.("Cancelled by caller", RPCStatusCode.CANCELLED),],)