Skip to content

Commit 4591fbc

Browse files
magik6krvagg
authored andcommitted
fix: Avoid panic edge-case in the API Proxy (#605)
1 parent a54ad6a commit 4591fbc

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

deps/apiinfo.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ func FullNodeProxy[T api.Chain](ins []T, outstr *api.ChainStruct) {
270270
}
271271
}
272272

273-
result, _ := Retry(ctx, maxRetryAttempts, initialBackoff, errorsToRetry, func(isRetry bool) ([]reflect.Value, error) {
273+
result, rerr := Retry(ctx, maxRetryAttempts, initialBackoff, errorsToRetry, func(isRetry bool) ([]reflect.Value, error) {
274274
if isRetry {
275275
pp := nextHealthyProvider(*preferredProvider + 1)
276276
if pp == -1 {
@@ -286,6 +286,18 @@ func FullNodeProxy[T api.Chain](ins []T, outstr *api.ChainStruct) {
286286
e := result[len(result)-1].Interface().(error)
287287
return result, e
288288
})
289+
if rerr != nil && field.Type.NumOut() != len(result) {
290+
clog.Errorw("retry rpc call error", "error", rerr, "result", result)
291+
292+
var out []reflect.Value
293+
for i := 0; i < field.Type.NumOut(); i++ {
294+
out = append(out, reflect.Zero(field.Type.Out(i)))
295+
}
296+
// last value is always an error.. set it to the error
297+
out[len(out)-1] = reflect.ValueOf(xerrors.Errorf("retry rpc call error: %w", rerr))
298+
return out
299+
}
300+
289301
return result
290302
}))
291303
}

0 commit comments

Comments
 (0)