Skip to content

Commit

Permalink
Fix race in WaitSignalReturnParam (#1309)
Browse files Browse the repository at this point in the history
  • Loading branch information
Quinn-With-Two-Ns authored Nov 30, 2023
1 parent a309e59 commit 266e049
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ func (ts *IntegrationTestSuite) TestWorkflowIDReuseIgnoreDuplicateWhileRunning()

// Send signal to each (though in practice they both have the same ID and run
// ID, so it's really just two signals)
err = ts.client.SignalWorkflow(ctx, run1.GetID(), run1.GetRunID(), "done-signal", true)
err = ts.client.SignalWorkflow(ctx, run1.GetID(), run1.GetRunID(), "done-signal", false)
ts.NoError(err)
err = ts.client.SignalWorkflow(ctx, run2.GetID(), run2.GetRunID(), "done-signal", true)
ts.NoError(err)
Expand Down
8 changes: 5 additions & 3 deletions test/workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1749,12 +1749,14 @@ func (w *Workflows) WaitSignalReturnParam(ctx workflow.Context, v interface{}) (
// Wait for signal before returning
s := workflow.NewSelector(ctx)
signalCh := workflow.GetSignalChannel(ctx, "done-signal")
var finishWf bool
s.AddReceive(signalCh, func(c workflow.ReceiveChannel, more bool) {
var ignore bool
c.Receive(ctx, &ignore)
c.Receive(ctx, &finishWf)
workflow.GetLogger(ctx).Info("Received signal")
})
s.Select(ctx)
for !finishWf {
s.Select(ctx)
}
return v, nil
}

Expand Down

0 comments on commit 266e049

Please sign in to comment.