Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle async call not being able to be called #1663

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions backend/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1219,19 +1219,21 @@ func (s *Service) executeAsyncCalls(ctx context.Context) (time.Duration, error)
Body: call.Request,
}
resp, err := s.callWithRequest(ctx, connect.NewRequest(req), optional.None[model.RequestKey](), s.config.Advertise.String())
if err != nil {
return 0, fmt.Errorf("async call failed: %w", err)
}
var callResult either.Either[[]byte, string]
if perr := resp.Msg.GetError(); perr != nil {
failed := false
if err != nil {
logger.Warnf("Async call could not be called: %v", err)
callResult = either.RightOf[[]byte](err.Error())
failed = true
} else if perr := resp.Msg.GetError(); perr != nil {
logger.Warnf("Async call failed: %s", perr.Message)
callResult = either.RightOf[[]byte](perr.Message)
failed = true
} else {
logger.Debugf("Async call succeeded")
callResult = either.LeftOf[string](resp.Msg.GetBody())
}
err = s.dal.CompleteAsyncCall(ctx, call, callResult, func(tx *dal.Tx) error {
failed := resp.Msg.GetError() != nil
if failed && call.RemainingAttempts > 0 {
// Will retry, do not propagate failure yet.
return nil
Expand Down
Loading