Skip to content

Commit

Permalink
fix: only cancel formatters on background errors
Browse files Browse the repository at this point in the history
If any of the formatting action returns an error, keep going to surface
as many errors as possible.

If the user hits Ctrl-C then terminate everything.
  • Loading branch information
zimbatm committed Jun 15, 2024
1 parent c68261e commit e29107d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cli/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,11 @@ func (f *Format) walkFilesystem(ctx context.Context) func() error {
}
}

// applyFormatters
func (f *Format) applyFormatters(ctx context.Context) func() error {
// create our own errgroup for concurrent formatting tasks
fg, ctx := errgroup.WithContext(ctx)
// create our own errgroup for concurrent formatting tasks.
// we don't want a cancel clause, in order to let formatters run up to the end.
fg := errgroup.Group{}
// simple optimization to avoid too many concurrent formatting tasks
// we can queue them up faster than the formatters can process them, this paces things a bit
fg.SetLimit(runtime.NumCPU())
Expand Down

0 comments on commit e29107d

Please sign in to comment.