Skip to content

Commit

Permalink
linter: use a buffered error channel
Browse files Browse the repository at this point in the history
This allows the linter to more gracefully exit from context
cancellation.

As seen in
https://github.com/StyraInc/regal/actions/runs/11233013451/job/31225814604,
this can cause test cases to timeout after there are errors.

My understanding the error being attempted to be sent to the channel is
a context cancellation error.

Signed-off-by: Charlie Egan <charlie@styra.com>
  • Loading branch information
charlieegan3 committed Oct 8, 2024
1 parent afce347 commit b19ea2c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/linter/linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,10 @@ func (l Linter) lintWithRegoRules(ctx context.Context, input rules.Input) (repor

var mu sync.Mutex

errCh := make(chan error)
// the error channel is buffered to prevent blocking
// caused by the context cancellation happening before
// errors are sent and the per-file goroutines can exit.
errCh := make(chan error, len(input.FileNames))
doneCh := make(chan bool)

for _, name := range input.FileNames {
Expand Down

0 comments on commit b19ea2c

Please sign in to comment.