diff --git a/builtin/bins/dkron-executor-nats/nats.go b/builtin/bins/dkron-executor-nats/nats.go index e918a0216..844f5eadd 100644 --- a/builtin/bins/dkron-executor-nats/nats.go +++ b/builtin/bins/dkron-executor-nats/nats.go @@ -73,6 +73,11 @@ func (s *Nats) ExecuteImpl(args *dktypes.ExecuteRequest) ([]byte, error) { if debug { log.Printf("request %#v\n\n", nc) } + + if nc.IsConnected() { + defer nc.Flush() + defer nc.Close() + } return output.Bytes(), nil }