fix(core): race cond in workflow execution

caused by shared context callbacks.

it was exposed after adding concurrent exec to
workflow processing and occurred when multiple
goroutines attempted to write to the same
`ctx.OnResult` callback field simultaneously,
causing data races during workflow template exec.

Signed-off-by: Dwi Siswanto <git@dw1.io>
This commit is contained in:
Dwi Siswanto 2025-09-25 09:23:10 +07:00
parent b7d0022c8d
commit 169d88e3bc
No known key found for this signature in database
GPG Key ID: 3BB198907EF44CED

View File

@ -38,8 +38,8 @@ func (e *Engine) executeWorkflow(ctx *scan.ScanContext, w *workflows.Workflow) b
go func(template *workflows.WorkflowTemplate) { go func(template *workflows.WorkflowTemplate) {
defer swg.Done() defer swg.Done()
newCtx := scan.NewScanContext(ctx.Context(), ctx.Input.Clone())
if err := e.runWorkflowStep(template, ctx, results, swg, w); err != nil { if err := e.runWorkflowStep(template, newCtx, results, swg, w); err != nil {
gologger.Warning().Msgf(workflowStepExecutionError, template.Template, err) gologger.Warning().Msgf(workflowStepExecutionError, template.Template, err)
} }
}(template) }(template)