|
25 | 25 | #' convention, is usually written in terms of powers of 2: |
26 | 26 | #' |
27 | 27 | #' ``` |
28 | | -#' b , 2b, 4b, 8b, ... |
| 28 | +#' b, 2b, 4b, 8b, ... |
29 | 29 | #' = b * 2^0, b * 2^1, b * 2^2, b * 2^3, ... |
30 | 30 | #' ``` |
31 | 31 | #' |
|
64 | 64 | #' can alternatively provide a datetime after which to retry, but we have no |
65 | 65 | #' first-hand experience with this variant for a Google API.) |
66 | 66 | #' * Sheets API quota exhaustion: In the course of googlesheets4 development, |
67 | | -#' we've grown very familiar with the `429 RESOURCE_EXHAUSTED` error. The |
68 | | -#' Sheets API v4 has "a limit of 500 requests per 100 seconds per project and |
69 | | -#' 100 requests per 100 seconds per user. Limits for reads and writes are |
70 | | -#' tracked separately." In our experience, the "100 (read or write) requests |
71 | | -#' per 100 seconds per user" limit is the one you hit most often. If we detect |
72 | | -#' this specific failure, the first wait time is a bit more than 100 seconds, |
73 | | -#' then we revert to exponential backoff. |
| 67 | +#' we've grown very familiar with the `429 RESOURCE_EXHAUSTED` error. As of |
| 68 | +#' 2023-04-15, the Sheets API v4 has a limit of 300 requests per minute per |
| 69 | +#' project and 60 requests per minute per user per project. Limits for reads |
| 70 | +#' and writes are tracked separately. In our experience, the "60 (read or |
| 71 | +#' write) requests per minute per user" limit is the one you hit most often. |
| 72 | +#' If we detect this specific failure, the first wait time is a bit more than |
| 73 | +#' one minute, then we revert to exponential backoff. |
| 74 | +#' |
74 | 75 | #' |
75 | 76 | #' @param ... Passed along to [request_make()]. |
76 | 77 | #' @param max_tries_total Maximum number of tries. |
@@ -155,8 +156,8 @@ backoff <- function(tries_made, |
155 | 156 | } |
156 | 157 |
|
157 | 158 | if (sheets_per_user_quota_exhaustion(resp) && tries_made == 1) { |
158 | | - wait_time <- 100 + stats::runif(1) |
159 | | - wait_rationale <- "fixed 100 second wait for per user quota exhaustion" |
| 159 | + wait_time <- 60 + stats::runif(1) |
| 160 | + wait_rationale <- "fixed 60 second wait for per user quota exhaustion" |
160 | 161 | } |
161 | 162 |
|
162 | 163 | retry_after <- retry_after_header(resp) |
@@ -203,7 +204,7 @@ sheets_per_user_quota_exhaustion <- function(resp) { |
203 | 204 | msg <- gargle_error_message(resp) |
204 | 205 | # the structure of this error and the wording of this message have changed |
205 | 206 | # over time |
206 | | - any(grepl("per user per 100 seconds", msg)) || |
| 207 | + any(grepl("per user per 60 seconds", msg)) || |
207 | 208 | any(grepl("per minute per user", msg)) |
208 | 209 | } |
209 | 210 |
|
|
0 commit comments