Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion R/pooled-request.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ PooledRequest <- R6Class(
)
handle_preflight(private$req_prep, private$handle)

curl::multi_add(
multi_add(
handle = private$handle,
pool = pool,
data = private$path,
Expand Down Expand Up @@ -155,3 +155,15 @@ PooledRequest <- R6Class(
}
)
)

# Wrapper around curl::multi_add() so that the pooled (async) request pathway
# has a mockable seam, mirroring curl_fetch() for the synchronous pathway.
multi_add <- function(handle, pool, data, done, fail) {
curl::multi_add(
handle = handle,
pool = pool,
data = data,
done = done,
fail = fail
)
}
4 changes: 2 additions & 2 deletions tests/testthat/test-req-perform-connection.R
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ test_that("tracing works as expected", {
resp <- req_perform_connection(request(url_build(parsed)))
close(resp)

# A request with a curl error.
# A request with a curl error
with_mocked_bindings(
try(req_perform_connection(request("http://127.0.0.1")), silent = TRUE),
curl_fetch = function(...) abort("Failed to connect")
open = function(...) stop("Failed to connect")
)

# A request that triggers retries, generating three individual spans.
Expand Down
7 changes: 6 additions & 1 deletion tests/testthat/test-req-promise.R
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,12 @@ test_that("tracing works as expected", {
p <- req_perform_promise(request("http://127.0.0.1"))
try(extract_promise(p), silent = TRUE)
},
curl_fetch = function(...) abort("Failed to connect")
multi_add = function(handle, pool, data, done, fail) {
fail(structure(
"Failed to connect",
class = c("curl_error_couldnt_connect", "curl_error", "character")
))
}
)

# A request with no parent context.
Expand Down
Loading