From e727641a9831c330d33b5c187e5988dafaf7b38f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Sat, 30 Sep 2023 21:37:12 +0800 Subject: [PATCH] Fix concurrent access on task returnError --- common/task/task.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/common/task/task.go b/common/task/task.go index dfc8cdef..5403481c 100644 --- a/common/task/task.go +++ b/common/task/task.go @@ -87,16 +87,18 @@ func (g *Group) RunContextList(contextList []context.Context) error { } selectedContext, upstreamErr := common.SelectContext(append([]context.Context{taskCancelContext}, contextList...)) - if selectedContext != 0 { - returnError = E.Append(returnError, upstreamErr, func(err error) error { - return E.Cause(err, "upstream") - }) - } if g.cleanup != nil { g.cleanup() } <-taskContext.Done() + + if selectedContext != 0 { + returnError = E.Append(returnError, upstreamErr, func(err error) error { + return E.Cause(err, "upstream") + }) + } + return returnError }