Skip to content

Commit

Permalink
Fix "stuck on build" in error situations in content processing
Browse files Browse the repository at this point in the history
Updates #8166
  • Loading branch information
bep committed Dec 23, 2021
1 parent 9eb0580 commit bd63c1a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion hugolib/pages_process.go
Expand Up @@ -115,17 +115,24 @@ type sitePagesProcessor struct {
m *pageMap
errorSender herrors.ErrorSender

ctx context.Context
itemChan chan interface{}
itemGroup *errgroup.Group
}

func (p *sitePagesProcessor) Process(item interface{}) error {
p.itemChan <- item
select {
case <-p.ctx.Done():
return nil
default:
p.itemChan <- item
}
return nil
}

func (p *sitePagesProcessor) Start(ctx context.Context) context.Context {
p.itemGroup, ctx = errgroup.WithContext(ctx)
p.ctx = ctx
p.itemGroup.Go(func() error {
for item := range p.itemChan {
if err := p.doProcess(item); err != nil {
Expand Down

0 comments on commit bd63c1a

Please sign in to comment.