From d1c7cf66df295082bbff9647aa7a89905e1d172b Mon Sep 17 00:00:00 2001 From: Jeremy Lucas Date: Mon, 1 Apr 2024 12:54:55 -0700 Subject: [PATCH] [Bugfix] Fixes a bug where tilenol writes to a disconnected client --- server.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server.go b/server.go index 93ab148..7833d91 100644 --- a/server.go +++ b/server.go @@ -2,6 +2,7 @@ package tilenol import ( "context" + "errors" "fmt" "io" "log" @@ -9,6 +10,7 @@ import ( "net/url" "strconv" "strings" + "syscall" "github.com/go-chi/chi" "github.com/go-chi/chi/middleware" @@ -383,6 +385,11 @@ func (s *Server) getVectorTile(w http.ResponseWriter, r *http.Request) { // handleError is a helper function to generate a generic tile server error response func (s *Server) handleError(err error, w http.ResponseWriter, r *http.Request) { + // Don't attempt to handle broken pipe errors (no one's listening on the other side!) + if errors.Is(err, syscall.EPIPE) { + return + } + var errCode int switch err.(type) { case InvalidRequestError: