From e374a7665ccd78d4ff5a1e6cbef015723609ac1c Mon Sep 17 00:00:00 2001 From: Peter Broadhurst Date: Thu, 28 Sep 2023 14:06:57 -0400 Subject: [PATCH 1/2] Honor comment of non-nil rpcRes even if context closed Signed-off-by: Peter Broadhurst --- pkg/rpcbackend/backend.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/rpcbackend/backend.go b/pkg/rpcbackend/backend.go index d642ad78..09c4ff33 100644 --- a/pkg/rpcbackend/backend.go +++ b/pkg/rpcbackend/backend.go @@ -149,7 +149,8 @@ func (rc *RPCClient) SyncRequest(ctx context.Context, rpcReq *RPCRequest) (rpcRe case rc.concurrencySlots <- true: // wait for the concurrency slot and continue case <-ctx.Done(): - return nil, i18n.NewError(ctx, signermsgs.MsgRequestCanceledContext, rpcReq.ID) + err := i18n.NewError(ctx, signermsgs.MsgRequestCanceledContext, rpcReq.ID) + return RPCErrorResponse(err, rpcReq.ID, RPCCodeInternalError), err } defer func() { <-rc.concurrencySlots From a5e84e149fdb0b91cd4cbb515c887bb915aba613 Mon Sep 17 00:00:00 2001 From: Peter Broadhurst Date: Thu, 28 Sep 2023 14:12:45 -0400 Subject: [PATCH 2/2] Ensure SyncRequest never returns nil, even if context is closed Signed-off-by: Peter Broadhurst --- .golangci.yml | 1 - config.md | 2 ++ go.mod | 2 +- go.sum | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 6c6e82f6..4d2b3a35 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -33,7 +33,6 @@ linters: enable: - bodyclose - deadcode - - depguard - dogsled - errcheck - goconst diff --git a/config.md b/config.md index a83cd8b0..312930e7 100644 --- a/config.md +++ b/config.md @@ -26,6 +26,7 @@ nav_order: 2 |expectContinueTimeout|See [ExpectContinueTimeout in the Go docs](https://pkg.go.dev/net/http#Transport)|[`time.Duration`](https://pkg.go.dev/time#Duration)|`1s` |headers|Adds custom headers to HTTP requests|`map[string]string`|`` |idleTimeout|The max duration to hold a HTTP keepalive connection between calls|[`time.Duration`](https://pkg.go.dev/time#Duration)|`475ms` +|maxConnsPerHost|The max number of connections, per unique hostname. Zero means no limit|`int`|`0` |maxIdleConns|The max number of idle connections to hold pooled|`int`|`100` |passthroughHeadersEnabled|Enable passing through the set of allowed HTTP request headers|`boolean`|`false` |requestTimeout|The maximum amount of time that a request is allowed to remain open|[`time.Duration`](https://pkg.go.dev/time#Duration)|`30s` @@ -69,6 +70,7 @@ nav_order: 2 |Key|Description|Type|Default Value| |---|-----------|----|-------------| +|connectionTimeout|The amount of time to wait while establishing a connection (or auto-reconnection)|[`time.Duration`](https://pkg.go.dev/time#Duration)|`45s` |heartbeatInterval|The amount of time to wait between heartbeat signals on the WebSocket connection|[`time.Duration`](https://pkg.go.dev/time#Duration)|`30s` |initialConnectAttempts|The number of attempts FireFly will make to connect to the WebSocket when starting up, before failing|`int`|`5` |path|The WebSocket sever URL to which FireFly should connect|WebSocket URL `string`|`` diff --git a/go.mod b/go.mod index 7aa04e38..8159eae1 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/fsnotify/fsnotify v1.6.0 github.com/go-resty/resty/v2 v2.7.0 github.com/gorilla/mux v1.8.0 - github.com/hyperledger/firefly-common v1.2.11 + github.com/hyperledger/firefly-common v1.3.0 github.com/karlseguin/ccache v2.0.3+incompatible github.com/pelletier/go-toml v1.9.5 github.com/santhosh-tekuri/jsonschema/v5 v5.0.2 diff --git a/go.sum b/go.sum index 81cd2629..5c0dffef 100644 --- a/go.sum +++ b/go.sum @@ -178,8 +178,8 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hyperledger/firefly-common v1.2.11 h1:ePDHJtorKE6ss8PtoPlyqLb+cB0TDB7ziM85Gtyerqs= -github.com/hyperledger/firefly-common v1.2.11/go.mod h1:17lOH4YufiPy82LpKm8fPa/YXJ0pUyq01zK1CmklJwM= +github.com/hyperledger/firefly-common v1.3.0 h1:eLFUJuPU8E5iZXYGHlXghQuN+opWG/qp7zvMKavKEPU= +github.com/hyperledger/firefly-common v1.3.0/go.mod h1:17lOH4YufiPy82LpKm8fPa/YXJ0pUyq01zK1CmklJwM= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=