diff --git a/server/broadcast.go b/server/broadcast.go index 8928bfd312..6ccfdd66ac 100755 --- a/server/broadcast.go +++ b/server/broadcast.go @@ -55,6 +55,7 @@ var submitMultiSession = func(ctx context.Context, sess *BroadcastSession, seg * nonce uint64, calcPerceptualHash bool, resc chan *SubmitResult) { go submitSegment(ctx, sess, seg, segPar, nonce, calcPerceptualHash, resc) } +var maxTranscodeAttempts = errors.New("hit max transcode attempts") type BroadcastConfig struct { maxPrice *big.Rat @@ -986,7 +987,7 @@ func processSegment(ctx context.Context, cxn *rtmpConnection, seg *stream.HLSSeg }() } if len(attempts) == MaxAttempts && err != nil { - err = fmt.Errorf("Hit max transcode attempts: %w", err) + err = fmt.Errorf("%w: %w", maxTranscodeAttempts, err) if monitor.Enabled { monitor.SegmentTranscodeFailed(ctx, monitor.SegmentTranscodeErrorMaxAttempts, nonce, seg.SeqNo, err, true) } @@ -1612,7 +1613,7 @@ func isNonRetryableError(err error) bool { return true } } - if strings.HasPrefix(err.Error(), "Hit max transcode attempts:") { + if errors.Is(err, maxTranscodeAttempts) { return true } return false diff --git a/server/broadcast_test.go b/server/broadcast_test.go index 14b95f14e9..8b2c6600cc 100644 --- a/server/broadcast_test.go +++ b/server/broadcast_test.go @@ -838,7 +838,8 @@ func TestProcessSegment_MaxAttempts(t *testing.T) { transcodeCalls = 0 _, err = processSegment(context.Background(), cxn, seg, nil) assert.NotNil(err) - assert.Equal("Hit max transcode attempts: UnknownResponse", err.Error()) + assert.True(errors.Is(err, maxTranscodeAttempts)) + assert.Equal("hit max transcode attempts: UnknownResponse", err.Error()) assert.Equal(1, transcodeCalls, "Segment submission calls did not match") assert.Len(bsm.trustedPool.sessMap, 1)