Fix incomplete debug message

that is created by sending SIGQUIT to the bash process
by not processing output after the the client disconnected / we have sent the SIGQUIT.
This commit is contained in:
Maximilian Paß
2023-08-01 12:25:10 +02:00
committed by Sebastian Serth
parent 0fd6e42487
commit 90092c48c1
3 changed files with 50 additions and 30 deletions

View File

@@ -44,6 +44,15 @@ func NewSentryDebugWriter(target io.Writer, ctx context.Context) *SentryDebugWri
// Improve: Handling of a split debug messages (usually, p is exactly one debug message, not less and not more).
func (s *SentryDebugWriter) Write(p []byte) (n int, err error) {
if s.Ctx.Err() != nil {
return 0, err
}
// Peaking if the target is able to write.
// If not we should not process the data (see #325).
if _, err = s.Target.Write([]byte{}); err != nil {
return 0, fmt.Errorf("SentryDebugWriter cannot write to target: %w", err)
}
if !timeDebugMessagePatternStart.Match(p) {
count, err := s.Target.Write(p)
if err != nil {