Skip to content

Commit e727641

Browse files
committed
Fix concurrent access on task returnError
1 parent 63b82af commit e727641

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

common/task/task.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,18 @@ func (g *Group) RunContextList(contextList []context.Context) error {
8787
}
8888

8989
selectedContext, upstreamErr := common.SelectContext(append([]context.Context{taskCancelContext}, contextList...))
90-
if selectedContext != 0 {
91-
returnError = E.Append(returnError, upstreamErr, func(err error) error {
92-
return E.Cause(err, "upstream")
93-
})
94-
}
9590

9691
if g.cleanup != nil {
9792
g.cleanup()
9893
}
9994

10095
<-taskContext.Done()
96+
97+
if selectedContext != 0 {
98+
returnError = E.Append(returnError, upstreamErr, func(err error) error {
99+
return E.Cause(err, "upstream")
100+
})
101+
}
102+
101103
return returnError
102104
}

0 commit comments

Comments
 (0)