From a1a35eb7be62309aad1c5ecf35746a9df636568f Mon Sep 17 00:00:00 2001 From: qwerty287 <80460567+qwerty287@users.noreply.github.com> Date: Tue, 24 Oct 2023 10:44:36 +0200 Subject: [PATCH] Fix error when closing logs (#2637) Previously, *all* log streams of the pipeline were closed everytime when a workflow is done, if you have multiple workflows, streams will be closed multiple times. Closes https://github.com/woodpecker-ci/woodpecker/issues/2036 --- server/grpc/rpc.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/server/grpc/rpc.go b/server/grpc/rpc.go index 7cbdd9a82..1d98b97a3 100644 --- a/server/grpc/rpc.go +++ b/server/grpc/rpc.go @@ -284,11 +284,9 @@ func (s *RPC) Done(c context.Context, id string, state rpc.State) error { // make sure writes to pubsub are non blocking (https://github.com/woodpecker-ci/woodpecker/blob/c919f32e0b6432a95e1a6d3d0ad662f591adf73f/server/logging/log.go#L9) go func() { - for _, wf := range currentPipeline.Workflows { - for _, step := range wf.Children { - if err := s.logger.Close(c, step.ID); err != nil { - logger.Error().Err(err).Msgf("done: cannot close log stream for step %d", step.ID) - } + for _, step := range workflow.Children { + if err := s.logger.Close(c, step.ID); err != nil { + logger.Error().Err(err).Msgf("done: cannot close log stream for step %d", step.ID) } } }()