Skip to content

Commit

Permalink
backend: increase default server write timeout (#998)
Browse files Browse the repository at this point in the history
For the List Messages endpoint that no longer uses
Websockets we have to upper the global write timeout
so that the ListMessages streaming response can
take longer than the current default of 30s.
  • Loading branch information
weeco authored Jan 11, 2024
1 parent eaaa3d1 commit 44d0135
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions backend/pkg/config/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
package config

import (
"time"

"github.com/cloudhut/common/rest"
)

Expand All @@ -29,5 +31,13 @@ type Server struct {
// SetDefaults for server config.
func (s *Server) SetDefaults() {
s.Config.SetDefaults()
// We use a timeout of up to 31 minutes in the ListMessages handler for certain requests.
// In the future we may be able to use http.NewResponseController to overwrite the global
// write timeout only for those routes that require to be run longer, but as of writing this
// it is not possible to set this from inside the connect handlers.
// References:
// 1. https://github.com/connectrpc/connect-go/issues/604
// 2. https://github.com/connectrpc/connect-go/issues/356
s.HTTPServerWriteTimeout = 32 * time.Minute
s.AllowedOrigins = nil
}

0 comments on commit 44d0135

Please sign in to comment.