@@ -290,26 +290,27 @@ func IsRetryableDNSError(err error) bool {
290290 return false
291291 }
292292
293- // Check for temporary network errors
294- var netErr * net.OpError
295- if errors .As (err , & netErr ) {
296- return netErr .Temporary ()
297- }
293+ // Use iterative approach to prevent stack overflow with deeply nested errors
294+ for err != nil {
295+ // Check for temporary network errors
296+ var netErr * net.OpError
297+ if errors .As (err , & netErr ) {
298+ return netErr .Temporary ()
299+ }
298300
299- // Check for context timeout (might be temporary)
300- if errors .Is (err , context .DeadlineExceeded ) {
301- return true
302- }
301+ // Check for context timeout (might be temporary)
302+ if errors .Is (err , context .DeadlineExceeded ) {
303+ return true
304+ }
303305
304- // Check for DNS-specific temporary failures
305- var dnsErr * net.DNSError
306- if errors .As (err , & dnsErr ) {
307- return dnsErr .Temporary ()
308- }
306+ // Check for DNS-specific temporary failures
307+ var dnsErr * net.DNSError
308+ if errors .As (err , & dnsErr ) {
309+ return dnsErr .Temporary ()
310+ }
309311
310- // Unwrap and check nested errors
311- if unwrapped := errors .Unwrap (err ); unwrapped != nil {
312- return IsRetryableDNSError (unwrapped )
312+ // Move to next error in chain
313+ err = errors .Unwrap (err )
313314 }
314315
315316 return false
0 commit comments