Skip to content
Myr

recovery: fix issue about syscall import on google app engine (#1640)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* recovery: fix issue about syscall import on google app engine * add ToLower() * the whole error message

authored by thinkerou · committed by Bo-Yi Wu · parent 3d44ff8 · Browse files · 2 files+4 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+4 added−4 removed

  • other:+4 added−4 removed

2 files+4 added−4 removed

modified:recovery_test.go+2 added-2 removed
82 unmodified lines
83func TestPanicWithBrokenPipe(t *testing.T) {84 const expectCode = 2048586 expectMsgs := map[syscall.Errno]string{87 syscall.EPIPE: "broken pipe",88 syscall.ECONNRESET: "connection reset",87 syscall.EPIPE: "Broken pipe",88 syscall.ECONNRESET: "connection reset by peer",89 }9091 for errno, expectMsg := range expectMsgs {92 t.Run(expectMsg, func(t *testing.T) {
22 unmodified lines
modified:recovery.go+2 added-2 removed
13 unmodified lines
14 "net/http"15 "net/http/httputil"16 "os"17 "runtime"18 "syscall"18 "strings"19 "time"20)2122var (
21 unmodified lines
44 // condition that warrants a panic stack trace.45 var brokenPipe bool46 if ne, ok := err.(*net.OpError); ok {47 if se, ok := ne.Err.(*os.SyscallError); ok {48 if se.Err == syscall.EPIPE || se.Err == syscall.ECONNRESET {48 if strings.Contains(strings.ToLower(se.Error()), "broken pipe") || strings.Contains(strings.ToLower(se.Error()), "connection reset by peer") {49 brokenPipe = true50 }51 }52 }
92 unmodified lines