Skip to content

Commit

Permalink
Merge pull request crossplane#4174 from phisco/dev/xfn_close_grpc_conn
Browse files Browse the repository at this point in the history
fix(xfn): close grpc connection with errors on options
  • Loading branch information
negz authored Jun 14, 2023
2 parents ff64756 + fcc80e7 commit 19b0823
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,8 @@ func RunFunction(ctx context.Context, fnio *iov1alpha1.FunctionIO, fn *v1.Contai
if err != nil {
return nil, errors.Wrap(err, errDialRunner)
}
// Remember to close the connection, we are not deferring it to be able to properly handle errors,
// without having to use a named return.

req := &fnv1alpha1.RunFunctionRequest{
Image: fn.Image,
Expand All @@ -815,6 +817,7 @@ func RunFunction(ctx context.Context, fnio *iov1alpha1.FunctionIO, fn *v1.Contai

for _, opt := range o {
if err := opt(ctx, fn, req); err != nil {
_ = conn.Close()
return nil, errors.Wrap(err, errApplyRunFunctionOption)
}
}
Expand Down

0 comments on commit 19b0823

Please sign in to comment.