Skip to content

Ministack: Free, open-source local AWS emulator - 60+ services, Terraform compatible, real databases. Free forever. MIT licensed.

fix: timeout in ws

Nahuel99084732696dc59
diff --git a/tests/test_apigatewayv2.py b/tests/test_apigatewayv2.py
index 173d12c2..9d2f1ff7 100644
--- a/tests/test_apigatewayv2.py
+++ b/tests/test_apigatewayv2.py
@@ -895,7 +895,14 @@ class _WSClient:
"""Blocking WebSocket client — just enough to drive tests."""
def __init__(self, host: str, port: int, path: str, headers: dict | None = None):
- self._sock = socket.create_connection((host, port), timeout=5)
+ # 30s instead of 5s: socket.create_connection sets both connect and
+ # recv timeout. The `$connect` Lambda invocation (cold-start +
+ # subprocess spawn under CI xdist contention on a 2-core Linux
+ # runner) can exceed 5s on the second WS attempt of tests that
+ # first reject without QS, then succeed with QS. The handshake
+ # itself is sub-ms once Lambda returns; 30s is well over worst
+ # observed cold-start latency without slowing real failures.
+ self._sock = socket.create_connection((host, port), timeout=30)
key = base64.b64encode(os.urandom(16)).decode()
request_headers = {
"Host": f"{host}:{port}",
diff --git a/tests/test_rds_data.py b/tests/test_rds_data.py
index c4f89511..65081651 100644
--- a/tests/test_rds_data.py
+++ b/tests/test_rds_data.py
@@ -32,8 +32,13 @@ def _raw_post(path, body):
headers={"Content-Type": "application/json"},
method="POST",
)
+ # 30s instead of 10s: under CI xdist contention the server's first
+ # call into _resolve_cluster triggers a lazy `from ministack.services
+ # import rds` whose import-time block can exceed 10s on the shared
+ # 2-core Linux runner. Handler itself is sub-ms once rds is loaded,
+ # so 30s leaves a wide margin without making real failures slow.
try:
- resp = urllib.request.urlopen(req, timeout=10)
+ resp = urllib.request.urlopen(req, timeout=30)
return resp.status, json.loads(resp.read())
except urllib.error.HTTPError as e:
return e.code, json.loads(e.read())