Skip to content

Commit 69afebb

Browse files
committed
deadlock oops
1 parent f366d18 commit 69afebb

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

partial.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,17 @@ func (p *Partial) mergeFuncMapInternal(funcMap template.FuncMap) {
179179
}
180180

181181
func (p *Partial) getFuncMap() template.FuncMap {
182+
p.mu.RLock()
183+
defer p.mu.RUnlock()
184+
182185
if p.parent != nil {
183-
p.mergeFuncMapInternal(p.parent.getFuncMap())
186+
for k, v := range p.parent.getFuncMap() {
187+
p.combinedFunctions[k] = v
188+
}
189+
184190
return p.combinedFunctions
185191
}
186192

187-
p.mu.RLock()
188-
defer p.mu.RUnlock()
189-
190193
return p.combinedFunctions
191194
}
192195

@@ -502,7 +505,10 @@ func (p *Partial) renderChildPartial(ctx context.Context, id string, data map[st
502505
child, ok := p.children[id]
503506
p.mu.RUnlock()
504507
if !ok {
505-
return "", fmt.Errorf("child partial '%s' not found", id)
508+
if p.logger != nil {
509+
p.logger.Warn("child partial not found", "id", id)
510+
}
511+
return "", nil
506512
}
507513

508514
// Clone the child partial to avoid modifying the original and prevent data races

0 commit comments

Comments
 (0)