Skip to content

Commit

Permalink
quit the inifinite loop of failing to refund just log once
Browse files Browse the repository at this point in the history
  • Loading branch information
binocarlos authored and simonwo committed May 3, 2023
1 parent 5c3296d commit 7b6bfdf
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pkg/bridge/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,20 @@ func (workflow *Workflow) ProcessEvent(ctx context.Context, event Event) (result
result = event.Failed(event.Error())
}
case OrderStateFailed:
result, err = workflow.Contract.Refund(ctx, event.(ContractFailedEvent))
// if we have failed we need to deal with the error that happens here
// differently than the normal "err" assignment that the other cases use
// if we were to assign an error to "err" then it would send it around
// an infinite "OrderStateFailed" loop
// so - we have already failed - let's just log that and move on
// TODO: we should absolutely do something if we have failed to refund the
// user - but we don't have time to do that thing right now so let's at least
// only log this error once and not loop infinitely
innerResult, refundError := workflow.Contract.Refund(ctx, event.(ContractFailedEvent))
log.Ctx(ctx).WithLevel(level(refundError)).
Err(refundError).
Msg("Refunding failed job")
result = innerResult

default:
result = nil
}
Expand Down

0 comments on commit 7b6bfdf

Please sign in to comment.