: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(framer): classify server-reported method timeouts as retryable (#128640)
Tom Owerscf852ca67ba2
diff --git a/products/warehouse_sources/sources/framer/framer.py b/products/warehouse_sources/sources/framer/framer.pyindex e29bd4b14555..f533c565ceb0 100644--- a/products/warehouse_sources/sources/framer/framer.py+++ b/products/warehouse_sources/sources/framer/framer.py@@ -258,6 +258,11 @@ class FramerClient:if message.get("type") == "methodResponse" and message.get("id") == invocation_id:error = message.get("error")if isinstance(error, str):+ # The server reports its own per-call timeout inline on an ordinary+ # methodResponse rather than the generic `{"type": "error"}` message+ # _receive() handles below, so it needs the same transient classification.+ if "timed out" in error.lower():+ raise FramerAPIError(f"{method}: {error}", code="TIMEOUT", retryable=True)raise FramerAPIError(f"{method}: {error}", code="METHOD_ERROR")return message.get("result")# Anything else (permissionUpdate, subscription traffic) is irrelevant here.diff --git a/products/warehouse_sources/sources/framer/tests/test_framer.py b/products/warehouse_sources/sources/framer/tests/test_framer.pyindex e59d86d4c97b..9efe484e37a8 100644--- a/products/warehouse_sources/sources/framer/tests/test_framer.py+++ b/products/warehouse_sources/sources/framer/tests/test_framer.py@@ -280,15 +280,27 @@ class TestFramer:assert exc_info.value.code == "CONNECTION_CLOSED"assert exc_info.value.retryable- def test_client_raises_on_method_error(self) -> None:+ @parameterized.expand(+ [+ ("generic", "Node not found", "METHOD_ERROR", False),+ # The server reports its own per-call timeout inline on the methodResponse,+ # not as the generic `{"type": "error"}` message tested below.+ ("method_timeout", 'Method "getNode" timed out after 120000ms', "TIMEOUT", True),+ ]+ )+ def test_client_raises_on_method_error(+ self, _name: str, error: str, expected_code: str, expected_retryable: bool+ ) -> None:server = FakeFramerServer()client = make_client(server)- server.enqueue_raw(devalue.stringify({"type": "methodResponse", "id": 0, "error": "Node not found"}))+ server.enqueue_raw(devalue.stringify({"type": "methodResponse", "id": 0, "error": error}))# Disable the auto-responder so the queued error response is the one consumed.server.auto_respond = Falsewith pytest.raises(FramerAPIError) as exc_info:client.call("getNode")- assert "Node not found" in str(exc_info.value)+ assert error in str(exc_info.value)+ assert exc_info.value.code == expected_code+ assert exc_info.value.retryable is expected_retryabledef test_client_reassembles_chunked_messages(self) -> None:server = FakeFramerServer()