: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(data-imports): treat a dropped Framer handshake as retryable (#114850)
Tom Owersf7562bb4585b
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/framer/framer.py b/products/warehouse_sources/backend/temporal/data_imports/sources/framer/framer.pyindex e95c6f46b20a..285bca244b3c 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/framer/framer.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/framer/framer.py@@ -212,6 +212,13 @@ class FramerClient:raise FramerAPIError(f"Connection closed during handshake: {e}", code="CONNECTION_CLOSED", retryable=True) from e+ except ConnectionClosed as e:+ # The TLS/TCP connection can also drop mid-handshake (e.g. a transient SSL error)+ # after the HTTP upgrade succeeds, which `websockets` surfaces as ConnectionClosed+ # rather than InvalidMessage. Same transient condition as the _receive() case below.+ raise FramerAPIError(+ f"Connection closed during handshake: {e}", code="CONNECTION_CLOSED", retryable=True+ ) from edeadline = time.monotonic() + CONNECT_TIMEOUT_SECONDSwhile True:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/framer/tests/test_framer.py b/products/warehouse_sources/backend/temporal/data_imports/sources/framer/tests/test_framer.pyindex 51e9e3d960d5..517427a81a6e 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/framer/tests/test_framer.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/framer/tests/test_framer.py@@ -10,7 +10,7 @@ from typing import Any, Optional, castimport pytestfrom parameterized import parameterized-from websockets.exceptions import InvalidMessage+from websockets.exceptions import ConnectionClosedError, InvalidMessagefrom products.warehouse_sources.backend.temporal.data_imports.sources.framer import devaluefrom products.warehouse_sources.backend.temporal.data_imports.sources.framer.framer import (@@ -265,9 +265,17 @@ class TestFramer:client.connect()assert exc_info.value.retryable- def test_client_wraps_handshake_eof_as_retryable(self) -> None:+ @parameterized.expand(+ [+ ("eof_before_response", InvalidMessage("did not receive a valid HTTP response")),+ # Raised when the TLS/TCP connection drops mid-handshake (e.g. a transient SSL+ # error) after the HTTP upgrade itself succeeds.+ ("dropped_mid_handshake", ConnectionClosedError(None, None)),+ ]+ )+ def test_client_wraps_handshake_failure_as_retryable(self, _name: str, raised: Exception) -> None:def connect_fn(*args: Any, **kwargs: Any) -> Any:- raise InvalidMessage("did not receive a valid HTTP response")+ raise raisedclient = FramerClient(PROJECT_ID, "test-key", protocol_version="0.1.29", connect_fn=connect_fn)with pytest.raises(FramerAPIError) as exc_info: