diff --git a/ChangeLog.md b/ChangeLog.md index a6d8fa8..49722a5 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,11 @@ ## Unreleased changes +## 0.29.1 + +- Improve reconnect handling. If the request to the node times out or fails due + to resource exhaustion then the connection to the node is longer reset. + ## 0.29.0 - Add an optional `success` field to the `transactionStatus` response if diff --git a/deps/concordium-client b/deps/concordium-client index fd3b287..ec19ec9 160000 --- a/deps/concordium-client +++ b/deps/concordium-client @@ -1 +1 @@ -Subproject commit fd3b2877118ffb759d93ff6758e64c2a713e03fe +Subproject commit ec19ec97e50ecca82e2365874b39e7be45a93d5d diff --git a/package.yaml b/package.yaml index 39014b5..b489ad3 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: wallet-proxy -version: 0.29.0 +version: 0.29.1 github: "Concordium/concordium-wallet-proxy" author: "Concordium" maintainer: "developers@concordium.com" diff --git a/src/Proxy.hs b/src/Proxy.hs index 42f3063..88085f1 100644 --- a/src/Proxy.hs +++ b/src/Proxy.hs @@ -59,7 +59,7 @@ import qualified Database.Esqueleto.Legacy as E import qualified Database.Esqueleto.PostgreSQL.JSON as EJ import Lens.Micro.Platform hiding ((.=)) import Network.GRPC.HTTP2.Types (GRPCStatusCode (..)) -import Network.HTTP.Types (Status, badGateway502, badRequest400, internalServerError500, notFound404) +import Network.HTTP.Types (Status, badGateway502, badRequest400, internalServerError500, notFound404, serviceUnavailable503) import System.Random import Text.Read hiding (String) import Web.Cookie @@ -174,7 +174,7 @@ share total_supply (Ratio Integer) |] -data ErrorCode = InternalError | RequestInvalid | DataNotFound +data ErrorCode = InternalError | RequestInvalid | DataNotFound | Unavailable deriving (Eq, Show, Enum) -- | Configuration for the @appSettings@ endpoint that returns whether the app is @@ -446,6 +446,18 @@ runGRPCWithCustomError resp c k = do StatusNotOk (NOT_FOUND, err) -> do return $ Left (StatusNotOkError NOT_FOUND, notFound404, DataNotFound, EMGRPCErrorResponse $ "Requested object was not found: " <> err) + -- GRPC response with status code 'CANCELLED', i.e., the server timed out the request. + StatusNotOk (CANCELLED, err) -> do + return $ + Left (StatusNotOkError CANCELLED, serviceUnavailable503, Unavailable, EMGRPCErrorResponse $ "The node is overloaded so the request was cancelled: " <> err) + -- GRPC response with status code 'RESOURCE_EXHAUSTED'. + StatusNotOk (RESOURCE_EXHAUSTED, err) -> do + return $ + Left (StatusNotOkError RESOURCE_EXHAUSTED, serviceUnavailable503, Unavailable, EMGRPCErrorResponse $ "The node is overloaded so the request was cancelled: " <> err) + -- GRPC response with status code 'DEADLINE_EXCEEDED' + StatusNotOk (DEADLINE_EXCEEDED, err) -> do + return $ + Left (StatusNotOkError DEADLINE_EXCEEDED, serviceUnavailable503, Unavailable, EMGRPCErrorResponse $ "The node is overloaded so the request was cancelled: " <> err) -- GRPC response with valid non-'OK' status code. StatusNotOk (status, err) -> do $(logError) $ "Got non-OK GRPC status code '" <> Text.pack (show status) <> "': " <> Text.pack err diff --git a/stack.yaml b/stack.yaml index cfa3de3..a4d17bf 100644 --- a/stack.yaml +++ b/stack.yaml @@ -49,7 +49,7 @@ extra-deps: commit: 4e9058db74e7a27dee0c92c4a754086e8a45a592 - github: Concordium/http2-grpc-haskell - commit: a4a0a31d44f754bf61868552ee5b256d94eed4de + commit: e52874ac2923f5177696e6dd4251fdb0f7dda87b subdirs: - http2-client-grpc - http2-grpc-proto-lens