-
Notifications
You must be signed in to change notification settings - Fork 24
Add timeout error classification #590
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,8 @@ | |
| from inspect import iscoroutinefunction | ||
| from typing import TYPE_CHECKING, Any | ||
|
|
||
| from awscrt.exceptions import AwsCrtError | ||
|
|
||
| if TYPE_CHECKING: | ||
| # pyright doesn't like optional imports. This is reasonable because if we use these | ||
| # in type hints then they'd result in runtime errors. | ||
|
|
@@ -33,6 +35,7 @@ | |
|
|
||
| from smithy_core import interfaces as core_interfaces | ||
| from smithy_core.aio import interfaces as core_aio_interfaces | ||
| from smithy_core.aio.interfaces import ErrorInfo | ||
| from smithy_core.aio.types import AsyncBytesReader | ||
| from smithy_core.exceptions import MissingDependencyError | ||
|
|
||
|
|
@@ -133,6 +136,22 @@ class AWSCRTHTTPClient(http_aio_interfaces.HTTPClient): | |
| _HTTP_PORT = 80 | ||
| _HTTPS_PORT = 443 | ||
|
|
||
| def get_error_info(self, exception: Exception, **kwargs: Any) -> ErrorInfo: | ||
| """Get information about CRT errors.""" | ||
|
|
||
| timeout_indicators = ( | ||
| "AWS_IO_SOCKET_TIMEOUT", | ||
| "AWS_IO_CHANNEL_ERROR_SOCKET_TIMEOUT", | ||
| "AWS_ERROR_HTTP_REQUEST_TIMEOUT", | ||
|
Comment on lines
+143
to
+145
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where are these coming from? Is this an exhaustive list for CRT errors? |
||
| ) | ||
| if isinstance(exception, TimeoutError): | ||
| return ErrorInfo(is_timeout_error=True, fault="client") | ||
|
|
||
| if isinstance(exception, AwsCrtError) and exception.name in timeout_indicators: | ||
| return ErrorInfo(is_timeout_error=True, fault="client") | ||
|
|
||
| return ErrorInfo(is_timeout_error=False) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why set |
||
|
|
||
| def __init__( | ||
| self, | ||
| eventloop: _AWSCRTEventLoop | None = None, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -215,7 +215,6 @@ async def _create_error( | |
| ) | ||
| return error_shape.deserialize(deserializer) | ||
|
|
||
| is_throttle = response.status == 429 | ||
| message = ( | ||
| f"Unknown error for operation {operation.schema.id} " | ||
| f"- status: {response.status}" | ||
|
|
@@ -224,11 +223,22 @@ async def _create_error( | |
| message += f" - id: {error_id}" | ||
| if response.reason is not None: | ||
| message += f" - reason: {response.status}" | ||
|
|
||
| if response.status == 408: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why special case 408? |
||
| is_timeout = True | ||
| fault = "server" | ||
| else: | ||
| is_timeout = False | ||
| fault = "client" if response.status < 500 else "server" | ||
|
|
||
| is_throttle = response.status == 429 | ||
|
|
||
| return CallError( | ||
| message=message, | ||
| fault="client" if response.status < 500 else "server", | ||
| fault=fault, | ||
| is_throttling_error=is_throttle, | ||
| is_retry_safe=is_throttle or None, | ||
| is_timeout_error=is_timeout, | ||
| is_retry_safe=is_throttle or is_timeout or None, | ||
| ) | ||
|
|
||
| def _matches_content_type(self, response: HTTPResponse) -> bool: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based off the docstring for ClientTimeoutError, shouldn't we be checking the fault value? What if the fault is set to server?