Skip to content

Commit 50f22ce

Browse files
authored
Fix retrying HTTP calls on DecodeError for dYdX (#2472)
1 parent 78d1a7a commit 50f22ce

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

nautilus_trader/adapters/dydx/endpoints/endpoint.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
Define the base class for dYdX endpoints.
1717
"""
1818

19-
from json import JSONDecodeError
2019
from typing import Any
2120

2221
import msgspec
22+
from msgspec import DecodeError
2323

2424
from nautilus_trader.adapters.dydx.common.enums import DYDXEndpointType
2525
from nautilus_trader.adapters.dydx.http.client import DYDXHttpClient
@@ -65,7 +65,7 @@ def __init__(
6565
max_retries=5,
6666
retry_delay_secs=1.0,
6767
logger=Logger(name="DYDXHttpEndpoint"),
68-
exc_types=(HttpTimeoutError, HttpError, DYDXError, JSONDecodeError),
68+
exc_types=(HttpTimeoutError, HttpError, DYDXError, DecodeError),
6969
retry_check=should_retry,
7070
)
7171

nautilus_trader/adapters/dydx/http/errors.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
Define a dYdX exception.
1717
"""
1818

19-
from json import JSONDecodeError
2019
from typing import Any
2120

2221
from grpc.aio._call import AioRpcError
22+
from msgspec import DecodeError
2323

2424
from nautilus_trader.adapters.dydx.common.constants import DYDX_RETRY_ERRORS_GRPC
2525
from nautilus_trader.adapters.dydx.grpc.errors import DYDXGRPCError
@@ -63,12 +63,7 @@ def should_retry(error: BaseException) -> bool:
6363

6464
if isinstance(
6565
error,
66-
AioRpcError
67-
| DYDXError
68-
| HttpError
69-
| HttpTimeoutError
70-
| WebSocketClientError
71-
| JSONDecodeError,
66+
AioRpcError | DYDXError | HttpError | HttpTimeoutError | WebSocketClientError | DecodeError,
7267
):
7368
return True
7469

0 commit comments

Comments
 (0)