Skip to content

Commit d2ab689

Browse files
djdvguseggert
authored andcommitted
fix: postrun's run condition in Execute
1 parent f661a07 commit d2ab689

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

executor.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,22 @@ func (x *executor) Execute(req *Request, re ResponseEmitter, env Environment) er
5656
postRunCh = make(chan error)
5757
)
5858

59-
if postRun == nil {
60-
close(postRunCh)
61-
return postRunCh
62-
}
63-
64-
// check if we have a formatter for this emitter type
59+
// Check if we have a formatter for this emitter type.
6560
typer, isTyper := re.(interface {
6661
Type() PostRunType
6762
})
68-
if isTyper &&
69-
formatters[typer.Type()] != nil {
63+
if isTyper {
7064
postRun = formatters[typer.Type()]
71-
} else {
65+
}
66+
// If not, just return nil via closing.
67+
if postRun == nil {
7268
close(postRunCh)
7369
return postRunCh
7470
}
7571

76-
// redirect emitter to us
77-
// and start waiting for emissions
72+
// Otherwise, relay emitter responses
73+
// from Run to PostRun, and
74+
// from PostRun to the original emitter.
7875
var (
7976
postRes Response
8077
postEmitter = re

0 commit comments

Comments
 (0)