Skip to content

Commit

Permalink
feat: return http 408 for timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
blombern committed Sep 23, 2024
1 parent effe201 commit c35493c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion server/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (n *Node) startProxyWorker(id int32, cancelContext context.Context) {

if time.Since(req.CreatedAt) > RequestTimeout {
_log.Info("request timed out before processing")
req.SendResponse(SimResponse{Error: ErrRequestTimeout})
req.SendResponse(SimResponse{Error: ErrRequestTimeout, StatusCode: http.StatusRequestTimeout})
continue
}

Expand Down
3 changes: 2 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package server

import (
"context"
"net/http"
"time"

"go.uber.org/zap"
Expand Down Expand Up @@ -78,7 +79,7 @@ func (s *Server) Start() {

if time.Since(r.CreatedAt) > RequestTimeout {
s.log.Info("request timed out before processing")
r.SendResponse(SimResponse{Error: ErrRequestTimeout})
r.SendResponse(SimResponse{Error: ErrRequestTimeout, StatusCode: http.StatusRequestTimeout})
continue
}

Expand Down

0 comments on commit c35493c

Please sign in to comment.