diff options
| author | Rutger Broekhoff | 2024-01-02 01:34:35 +0100 |
|---|---|---|
| committer | Rutger Broekhoff | 2024-01-02 01:34:35 +0100 |
| commit | 6dcf47216ae9c0823eec754de4ebb133843f2bac (patch) | |
| tree | 56b4042323e000cb9fb2c2219b5159fcd1c1f5ec /cmd/git-lfs-server | |
| parent | e0c72c187d39ed7caa0f45ad4935513d435925ed (diff) | |
| download | gitolfs3-6dcf47216ae9c0823eec754de4ebb133843f2bac.tar.gz gitolfs3-6dcf47216ae9c0823eec754de4ebb133843f2bac.zip | |
catch panic
Diffstat (limited to 'cmd/git-lfs-server')
| -rw-r--r-- | cmd/git-lfs-server/main.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/cmd/git-lfs-server/main.go b/cmd/git-lfs-server/main.go index 0379117..e5fd7d1 100644 --- a/cmd/git-lfs-server/main.go +++ b/cmd/git-lfs-server/main.go | |||
| @@ -20,6 +20,7 @@ import ( | |||
| 20 | "os/exec" | 20 | "os/exec" |
| 21 | "path" | 21 | "path" |
| 22 | "regexp" | 22 | "regexp" |
| 23 | "runtime/debug" | ||
| 23 | "slices" | 24 | "slices" |
| 24 | "strconv" | 25 | "strconv" |
| 25 | "strings" | 26 | "strings" |
| @@ -588,7 +589,15 @@ func (h *handler) handleBatchAPI(w http.ResponseWriter, r *http.Request, repo st | |||
| 588 | } | 589 | } |
| 589 | 590 | ||
| 590 | func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | 591 | func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { |
| 591 | ctx := context.WithValue(r.Context(), requestIDKey, xid.New().String()) | 592 | reqID := xid.New().String() |
| 593 | ctx := context.WithValue(r.Context(), requestIDKey, reqID) | ||
| 594 | w.Header().Set("X-Request-Id", reqID) | ||
| 595 | |||
| 596 | defer func() { | ||
| 597 | if r := recover(); r != nil { | ||
| 598 | reqlog(ctx, "Panic when serving request: %s", debug.Stack()) | ||
| 599 | } | ||
| 600 | }() | ||
| 592 | 601 | ||
| 593 | reqPath := os.Getenv("PATH_INFO") | 602 | reqPath := os.Getenv("PATH_INFO") |
| 594 | if reqPath == "" { | 603 | if reqPath == "" { |