diff --git a/modules/git/batch_reader.go b/modules/git/batch_reader.go index 5a0a82b13a9c8..902fa897185f5 100644 --- a/modules/git/batch_reader.go +++ b/modules/git/batch_reader.go @@ -57,6 +57,12 @@ func CatFileBatchCheck(ctx context.Context, repoPath string) (WriteCloserError, <-closed } + // Ensure cancel is called as soon as the provided context is cancelled + go func() { + <-ctx.Done() + cancel() + }() + _, filename, line, _ := runtime.Caller(2) filename = strings.TrimPrefix(filename, callerPrefix) @@ -101,6 +107,12 @@ func CatFileBatch(ctx context.Context, repoPath string) (WriteCloserError, *bufi <-closed } + // Ensure cancel is called as soon as the provided context is cancelled + go func() { + <-ctx.Done() + cancel() + }() + _, filename, line, _ := runtime.Caller(2) filename = strings.TrimPrefix(filename, callerPrefix)