diff --git a/api/server.go b/api/server.go index b73165b3a..b4b8d97d5 100644 --- a/api/server.go +++ b/api/server.go @@ -189,7 +189,9 @@ func (h *Server) Start() error { CheckTimeouts(h.logger, &h.timeouts) h.server.ReadTimeout = h.timeouts.ReadTimeout h.server.ReadHeaderTimeout = h.timeouts.ReadHeaderTimeout - h.server.WriteTimeout = h.timeouts.WriteTimeout + // WriteTimeout is the maximum duration before timing out + // writes of the response, a.k.a JSON-RPC request timeout. + h.server.WriteTimeout = h.config.RpcRequestTimeout h.server.IdleTimeout = h.timeouts.IdleTimeout } diff --git a/cmd/run/cmd.go b/cmd/run/cmd.go index 00274cc7f..871b35784 100644 --- a/cmd/run/cmd.go +++ b/cmd/run/cmd.go @@ -291,6 +291,7 @@ func init() { Cmd.Flags().BoolVar(&cfg.TxBatchMode, "tx-batch-mode", false, "Enable batch transaction submission, to avoid nonce mismatch issues for high-volume EOAs.") Cmd.Flags().DurationVar(&cfg.TxBatchInterval, "tx-batch-interval", time.Millisecond*1200, "Time interval upon which to submit the transaction batches to the Flow network.") Cmd.Flags().DurationVar(&cfg.EOAActivityCacheTTL, "eoa-activity-cache-ttl", time.Second*10, "Time interval used to track EOA activity. Tx send more frequently than this interval will be batched. Useful only when batch transaction submission is enabled.") + Cmd.Flags().DurationVar(&cfg.RpcRequestTimeout, "rpc-request-timeout", time.Second*120, "Sets the maximum duration at which JSON-RPC requests should generate a response, before they timeout. The default is 120 seconds.") err := Cmd.Flags().MarkDeprecated("init-cadence-height", "This flag is no longer necessary and will be removed in future version. The initial Cadence height is known for testnet/mainnet and this was only required for fresh deployments of EVM Gateway. Once the DB has been initialized, the latest index Cadence height will be used upon start-up.") if err != nil { diff --git a/config/config.go b/config/config.go index 42529a1e1..acd1adcfa 100644 --- a/config/config.go +++ b/config/config.go @@ -124,4 +124,7 @@ type Config struct { // frequently than this interval will be batched. // Useful only when batch transaction submission is enabled. EOAActivityCacheTTL time.Duration + // RpcRequestTimeout is the maximum duration at which JSON-RPC requests should generate + // a response, before they timeout. + RpcRequestTimeout time.Duration }