namedotcom / go

Name.com API Go Client.
https://www.name.com/api-docs
MIT License
14 stars 8 forks source link

What to do about timeouts? #6

Open tlimoncelli opened 3 years ago

tlimoncelli commented 3 years ago

When doing large updates (for example, creating 20 A records) I sometimes get this error:

Post "https://api.name.com/v4/domains/dnscontrol-ndc.com/records": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

Ideally the library should silently retry, or at least provide enough feedback so that I can do the re-try.

sadly doing my own retry didn't work. I tried this but got the error Invalid Argument: Parameter Value Error - Dns Error:

+       if err != nil {
+               if strings.Contains(err.Error(), "context deadline exceeded") {
+                       fmt.Printf("INFO: Sleeping then re-trying due to error: %s\n", err)
+                       time.Sleep(1 * time.Second)
+                       goto retry
+               }
+       }

Suggestions on how to handle this?

patramsey commented 3 years ago

@tlimoncelli sorry for the delayed response. Was the request trying to create 20 A records in one request, or 20 A records on 20 HTTP requests?

tlimoncelli commented 3 years ago

I haven't seen this issue in a while. Maybe namedotcom was just slow over the holidays.

Here's an example where there was an error:

Search for 2020-12-28T19:34:23.4234732Z or context deadline exceeded: Log file

Here's an example where it succeeded: Go to https://github.com/StackExchange/dnscontrol/runs/2184116928?check_suite_focus=true click on "Run integration tests for NAMEDOTCOM provider" then scroll to line 530. (That time it succeeded)