Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test this on stage #926

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions graphql_api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import socket
import time
from asyncio import iscoroutine
from asyncio import iscoroutine, wait_for
from typing import Any, Collection, Optional

import regex
Expand Down Expand Up @@ -239,7 +239,12 @@ async def post(self, request, *args, **kwargs):
)

with RequestFinalizer(request):
response = await super().post(request, *args, **kwargs)
try:
response = await wait_for(
super().post(request, *args, **kwargs), timeout=3
)
except TimeoutError:
return JsonResponse({"error": "Request timed out"}, status=408)

content = response.content.decode("utf-8")
data = json.loads(content)
Expand Down Expand Up @@ -287,9 +292,7 @@ def error_formatter(self, error, debug=False):
formatted["type"] = "ServerError"
# if this is one of our own command exception, we can tell a bit more
original_error = error.original_error
if isinstance(original_error, BaseException) or isinstance(
original_error, ServiceException
):
if isinstance(original_error, (BaseException, ServiceException, TimeoutError)):
formatted["message"] = original_error.message
formatted["type"] = type(original_error).__name__
else:
Expand Down
Loading