Skip to content

Commit a2ac8e5

Browse files
committed
fix external render ctx
1 parent 08f0f69 commit a2ac8e5

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

modules/markup/external/external.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ func (p *Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io.
102102

103103
_, err = io.Copy(f, input)
104104
if err != nil {
105-
f.Close()
105+
_ = f.Close()
106106
return fmt.Errorf("%s write data to temp file when rendering %s failed: %w", p.Name(), p.Command, err)
107107
}
108108

@@ -113,10 +113,9 @@ func (p *Renderer) Render(ctx *markup.RenderContext, input io.Reader, output io.
113113
args = append(args, f.Name())
114114
}
115115

116-
if ctx == nil || ctx.Ctx == nil {
117-
if ctx == nil {
118-
log.Warn("RenderContext not provided defaulting to empty ctx")
119-
ctx = &markup.RenderContext{}
116+
if ctx.Ctx == nil {
117+
if !setting.IsProd || setting.IsInTesting {
118+
panic("RenderContext did not provide context")
120119
}
121120
log.Warn("RenderContext did not provide context, defaulting to Shutdown context")
122121
ctx.Ctx = graceful.GetManager().ShutdownContext()

0 commit comments

Comments
 (0)