From c44237231fee2607b9ddc3efc6befe8f2e378142 Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Fri, 16 Aug 2024 11:41:33 +0530 Subject: [PATCH 1/2] fix: timeout --- CHANGELOG.md | 4 ++++ setup.py | 2 +- supertokens_python/constants.py | 2 +- supertokens_python/querier.py | 2 +- supertokens_python/recipe/dashboard/api/analytics.py | 2 +- .../emaildelivery/services/backward_compatibility/__init__.py | 2 +- .../emaildelivery/services/backward_compatibility/__init__.py | 2 +- .../emaildelivery/services/backward_compatibility/__init__.py | 2 +- .../smsdelivery/services/backward_compatibility/__init__.py | 2 +- .../passwordless/smsdelivery/services/supertokens/__init__.py | 2 +- supertokens_python/recipe/thirdparty/providers/custom.py | 2 +- supertokens_python/recipe/thirdparty/providers/utils.py | 4 ++-- 12 files changed, 16 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44d8edaf4..db69f5e2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [unreleased] +## [0.24.1] - 2024-08-16 + +- Sets no time out for http client in querier and 30s everywhere else. - https://github.com/supertokens/supertokens-python/issues/516 + ## [0.24.0] - 2024-07-31 ### Changes diff --git a/setup.py b/setup.py index 4b3896190..9a896818f 100644 --- a/setup.py +++ b/setup.py @@ -83,7 +83,7 @@ setup( name="supertokens_python", - version="0.24.0", + version="0.24.1", author="SuperTokens", license="Apache 2.0", author_email="team@supertokens.com", diff --git a/supertokens_python/constants.py b/supertokens_python/constants.py index f7e60529a..2f3242fa9 100644 --- a/supertokens_python/constants.py +++ b/supertokens_python/constants.py @@ -14,7 +14,7 @@ from __future__ import annotations SUPPORTED_CDI_VERSIONS = ["3.0"] -VERSION = "0.24.0" +VERSION = "0.24.1" TELEMETRY = "/telemetry" USER_COUNT = "/users/count" USER_DELETE = "/user/remove" diff --git a/supertokens_python/querier.py b/supertokens_python/querier.py index be1278b86..7c8305fef 100644 --- a/supertokens_python/querier.py +++ b/supertokens_python/querier.py @@ -106,7 +106,7 @@ async def api_request( raise Exception("Retry request failed") try: - async with AsyncClient() as client: + async with AsyncClient(timeout=None) as client: if method == "GET": return await client.get(url, *args, **kwargs) # type: ignore if method == "POST": diff --git a/supertokens_python/recipe/dashboard/api/analytics.py b/supertokens_python/recipe/dashboard/api/analytics.py index e5faba3a9..420b9f99f 100644 --- a/supertokens_python/recipe/dashboard/api/analytics.py +++ b/supertokens_python/recipe/dashboard/api/analytics.py @@ -93,7 +93,7 @@ async def handle_analytics_post( data["telemetryId"] = telemetry_id try: - async with AsyncClient() as client: + async with AsyncClient(timeout=30.0) as client: await client.post( # type: ignore url=TELEMETRY_SUPERTOKENS_API_URL, json=data, diff --git a/supertokens_python/recipe/emailpassword/emaildelivery/services/backward_compatibility/__init__.py b/supertokens_python/recipe/emailpassword/emaildelivery/services/backward_compatibility/__init__.py index 3fb2a7789..ee295789e 100644 --- a/supertokens_python/recipe/emailpassword/emaildelivery/services/backward_compatibility/__init__.py +++ b/supertokens_python/recipe/emailpassword/emaildelivery/services/backward_compatibility/__init__.py @@ -41,7 +41,7 @@ async def create_and_send_email_using_supertokens_service( "passwordResetURL": password_reset_url_with_token, } try: - async with AsyncClient() as client: + async with AsyncClient(timeout=30.0) as client: resp = await client.post("https://api.supertokens.io/0/st/auth/password/reset", json=data, headers={"api-version": "0"}) # type: ignore resp.raise_for_status() log_debug_message("Password reset email sent to %s", user.email) diff --git a/supertokens_python/recipe/emailverification/emaildelivery/services/backward_compatibility/__init__.py b/supertokens_python/recipe/emailverification/emaildelivery/services/backward_compatibility/__init__.py index b78891e3f..128cef084 100644 --- a/supertokens_python/recipe/emailverification/emaildelivery/services/backward_compatibility/__init__.py +++ b/supertokens_python/recipe/emailverification/emaildelivery/services/backward_compatibility/__init__.py @@ -38,7 +38,7 @@ async def create_and_send_email_using_supertokens_service( "emailVerifyURL": email_verification_url, } try: - async with AsyncClient() as client: + async with AsyncClient(timeout=30.0) as client: resp = await client.post("https://api.supertokens.io/0/st/auth/email/verify", json=data, headers={"api-version": "0"}) # type: ignore resp.raise_for_status() log_debug_message("Email verification email sent to %s", user.email) diff --git a/supertokens_python/recipe/passwordless/emaildelivery/services/backward_compatibility/__init__.py b/supertokens_python/recipe/passwordless/emaildelivery/services/backward_compatibility/__init__.py index 630adc2d1..d4b274a75 100644 --- a/supertokens_python/recipe/passwordless/emaildelivery/services/backward_compatibility/__init__.py +++ b/supertokens_python/recipe/passwordless/emaildelivery/services/backward_compatibility/__init__.py @@ -45,7 +45,7 @@ async def create_and_send_email_with_supertokens_service( data["userInputCode"] = input_.user_input_code try: - async with AsyncClient() as client: + async with AsyncClient(timeout=30.0) as client: resp = await client.post("https://api.supertokens.io/0/st/auth/passwordless/login", json=data, headers={"api-version": "0"}) # type: ignore resp.raise_for_status() log_debug_message("Passwordless login email sent to %s", input_.email) diff --git a/supertokens_python/recipe/passwordless/smsdelivery/services/backward_compatibility/__init__.py b/supertokens_python/recipe/passwordless/smsdelivery/services/backward_compatibility/__init__.py index 8b79ccbea..9129da29d 100644 --- a/supertokens_python/recipe/passwordless/smsdelivery/services/backward_compatibility/__init__.py +++ b/supertokens_python/recipe/passwordless/smsdelivery/services/backward_compatibility/__init__.py @@ -46,7 +46,7 @@ async def create_and_send_sms_using_supertokens_service( sms_input_json["urlWithLinkCode"] = input_.url_with_link_code try: - async with AsyncClient() as client: + async with AsyncClient(timeout=30.0) as client: res = await client.post( # type: ignore SUPERTOKENS_SMS_SERVICE_URL, json={ diff --git a/supertokens_python/recipe/passwordless/smsdelivery/services/supertokens/__init__.py b/supertokens_python/recipe/passwordless/smsdelivery/services/supertokens/__init__.py index a25be8d0e..09669357a 100644 --- a/supertokens_python/recipe/passwordless/smsdelivery/services/supertokens/__init__.py +++ b/supertokens_python/recipe/passwordless/smsdelivery/services/supertokens/__init__.py @@ -50,7 +50,7 @@ async def send_sms( if template_vars.user_input_code: sms_input["userInputCode"] = template_vars.user_input_code try: - async with AsyncClient() as client: + async with AsyncClient(timeout=30.0) as client: await client.post( # type: ignore SUPERTOKENS_SMS_SERVICE_URL, json={ diff --git a/supertokens_python/recipe/thirdparty/providers/custom.py b/supertokens_python/recipe/thirdparty/providers/custom.py index 8da6de021..9b6a355de 100644 --- a/supertokens_python/recipe/thirdparty/providers/custom.py +++ b/supertokens_python/recipe/thirdparty/providers/custom.py @@ -156,7 +156,7 @@ async def verify_id_token_from_jwks_endpoint_and_get_payload( id_token: str, jwks_uri: str, audience: str ): public_keys: List[RSAAlgorithm] = [] - async with AsyncClient() as client: + async with AsyncClient(timeout=30.0) as client: response = await client.get(jwks_uri) # type:ignore key_payload = response.json() for key in key_payload["keys"]: diff --git a/supertokens_python/recipe/thirdparty/providers/utils.py b/supertokens_python/recipe/thirdparty/providers/utils.py index 875b0118d..9f9aaf80b 100644 --- a/supertokens_python/recipe/thirdparty/providers/utils.py +++ b/supertokens_python/recipe/thirdparty/providers/utils.py @@ -36,7 +36,7 @@ async def do_get_request( if headers is None: headers = {} - async with AsyncClient() as client: + async with AsyncClient(timeout=30.0) as client: res = await client.get(url, params=query_params, headers=headers) # type:ignore log_debug_message( @@ -59,7 +59,7 @@ async def do_post_request( headers["content-type"] = "application/x-www-form-urlencoded" headers["accept"] = "application/json" - async with AsyncClient() as client: + async with AsyncClient(timeout=30.0) as client: res = await client.post(url, data=body_params, headers=headers) # type:ignore log_debug_message( "Received response with status %s and body %s", res.status_code, res.text From 0795185b13d3e5638bc221e11c1e0b70052f0c22 Mon Sep 17 00:00:00 2001 From: Sattvik Chakravarthy Date: Fri, 16 Aug 2024 12:12:24 +0530 Subject: [PATCH 2/2] fix: timeout --- CHANGELOG.md | 2 +- supertokens_python/querier.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db69f5e2f..04e549b0f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [0.24.1] - 2024-08-16 -- Sets no time out for http client in querier and 30s everywhere else. - https://github.com/supertokens/supertokens-python/issues/516 +- Sets time out for httpx client to 30s everywhere. - https://github.com/supertokens/supertokens-python/issues/516 ## [0.24.0] - 2024-07-31 diff --git a/supertokens_python/querier.py b/supertokens_python/querier.py index 7c8305fef..6382f4cd1 100644 --- a/supertokens_python/querier.py +++ b/supertokens_python/querier.py @@ -106,7 +106,7 @@ async def api_request( raise Exception("Retry request failed") try: - async with AsyncClient(timeout=None) as client: + async with AsyncClient(timeout=30.0) as client: if method == "GET": return await client.get(url, *args, **kwargs) # type: ignore if method == "POST":