From bd63c1aa56e05e88b162e9fd19b6d21fbc609df7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Wed, 22 Dec 2021 19:00:32 +0100 Subject: [PATCH] Fix "stuck on build" in error situations in content processing Updates #8166 --- hugolib/pages_process.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hugolib/pages_process.go b/hugolib/pages_process.go index 89a306a3bb5..541c0ae3e45 100644 --- a/hugolib/pages_process.go +++ b/hugolib/pages_process.go @@ -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 {