Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.

Commit 0bd9229

Browse files
committed
Merge branch 'Ajay/920-batching-dos-attack' into staging
2 parents 4e9c42d + 4bec180 commit 0bd9229

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

graphql_api/views.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
import socket
55
import time
6-
from asyncio import iscoroutine
6+
from asyncio import iscoroutine, wait_for
77
from typing import Any, Collection, Optional
88

99
import regex
@@ -239,7 +239,12 @@ async def post(self, request, *args, **kwargs):
239239
)
240240

241241
with RequestFinalizer(request):
242-
response = await super().post(request, *args, **kwargs)
242+
try:
243+
response = await wait_for(
244+
super().post(request, *args, **kwargs), timeout=3
245+
)
246+
except TimeoutError:
247+
return JsonResponse({"error": "Request timed out"}, status=408)
243248

244249
content = response.content.decode("utf-8")
245250
data = json.loads(content)

0 commit comments

Comments
 (0)