|
8 | 8 | "sync/atomic" |
9 | 9 | "time" |
10 | 10 |
|
11 | | - "github.com/getsentry/raven-go" |
| 11 | + "github.com/getsentry/sentry-go" |
12 | 12 | "github.com/pkg/errors" |
13 | 13 | "github.com/rs/zerolog" |
14 | 14 |
|
@@ -58,24 +58,15 @@ func unidirectionalStream(dst io.Writer, src io.Reader, dir string, status *bidi |
58 | 58 | // server/origin listens forever until closure), it may read/write from the underlying ReadWriter (backed by |
59 | 59 | // the Edge<->cloudflared transport) in an unexpected state. |
60 | 60 | // Because of this, we set this recover() logic. |
61 | | - if r := recover(); r != nil { |
| 61 | + if err := recover(); err != nil { |
62 | 62 | if status.isAnyDone() { |
63 | 63 | // We handle such unexpected errors only when we detect that one side of the streaming is done. |
64 | | - log.Debug().Msgf("Gracefully handled error %v in Streaming for %s, error %s", r, dir, debug.Stack()) |
| 64 | + log.Debug().Msgf("recovered from panic in stream.Pipe for %s, error %s, %s", dir, err, debug.Stack()) |
65 | 65 | } else { |
66 | 66 | // Otherwise, this is unexpected, but we prevent the program from crashing anyway. |
67 | | - log.Warn().Msgf("Gracefully handled unexpected error %v in Streaming for %s, error %s", r, dir, debug.Stack()) |
68 | | - |
69 | | - tags := make(map[string]string) |
70 | | - tags["root"] = "websocket.stream" |
71 | | - tags["dir"] = dir |
72 | | - switch rval := r.(type) { |
73 | | - case error: |
74 | | - raven.CaptureError(rval, tags) |
75 | | - default: |
76 | | - rvalStr := fmt.Sprint(rval) |
77 | | - raven.CaptureMessage(rvalStr, tags) |
78 | | - } |
| 67 | + log.Warn().Msgf("recovered from panic in stream.Pipe for %s, error %s, %s", dir, err, debug.Stack()) |
| 68 | + sentry.CurrentHub().Recover(err) |
| 69 | + sentry.Flush(time.Second * 5) |
79 | 70 | } |
80 | 71 | } |
81 | 72 | }() |
|
0 commit comments