Panic when Timeout if setup output variable in function
chucobo124 opened this issue · 0 comments
chucobo124 commented
Here is the issue when I do this.
func FetchReq() (ids []string, err error) {
err = hystrix.Do("FetchA", func() error {
for _ , id := range fetchRequest() {
ids = append(ids, fmt.Sprintf("%d", id))
}
}
if len(str) == 0 {
return nil , errors.New("No response")
}
return str , nil
}
If there is a timeout in fetchRequest
we will get the panic say ids is nil in for block
It's similar to this problem.
https://play.golang.org/p/5LEjvISGuE4
I think we can have another way to solve this error when timeout.
solving like this to exit when timeout.
https://play.golang.org/p/PRsgLmUMSsQ
The error can be referred to this line.
https://github.com/afex/hystrix-go/blob/master/hystrix/hystrix.go#L205