Fix "stuck on build" in error situations in content processing

Updates #8166
This commit is contained in:
Bjørn Erik Pedersen 2021-12-22 19:00:32 +01:00
parent 9eb05807c6
commit bd63c1aa56

View file

@ -115,17 +115,24 @@ type sitePagesProcessor struct {
m *pageMap m *pageMap
errorSender herrors.ErrorSender errorSender herrors.ErrorSender
ctx context.Context
itemChan chan interface{} itemChan chan interface{}
itemGroup *errgroup.Group itemGroup *errgroup.Group
} }
func (p *sitePagesProcessor) Process(item interface{}) error { func (p *sitePagesProcessor) Process(item interface{}) error {
p.itemChan <- item select {
case <-p.ctx.Done():
return nil
default:
p.itemChan <- item
}
return nil return nil
} }
func (p *sitePagesProcessor) Start(ctx context.Context) context.Context { func (p *sitePagesProcessor) Start(ctx context.Context) context.Context {
p.itemGroup, ctx = errgroup.WithContext(ctx) p.itemGroup, ctx = errgroup.WithContext(ctx)
p.ctx = ctx
p.itemGroup.Go(func() error { p.itemGroup.Go(func() error {
for item := range p.itemChan { for item := range p.itemChan {
if err := p.doProcess(item); err != nil { if err := p.doProcess(item); err != nil {