Closed asadow closed 11 months ago
Looks like cache
was just added to the dev version of httr2, not yet released: https://github.com/r-lib/httr2/commit/6b085735f37a34130c5c27213faec78825ebc86e#diff-95a582a44f505a6f9643d2348d2a0c0c5a9499602f36fa9a3943380195b2fde6R94
We should add response$cache <- NULL
around here so that we don't include it in saved responses because the environment won't serialize (and is a cache anyway so not strictly necessary). Would you like to submit a PR?
cache = NULL
in the mock file gives an error:
#> Error in `req_perform()`:
#> ! Failed to parse error body with method defined in `req_error()`.
#> Caused by error in `env_has()`:
#> ! `env` must be an environment, not `NULL`.
Setting cache = rlang::caller_env()
fixes it. Does adding response$cache <- rlang::caller_env()
make sense?
I'll have to look into it more then, may have to create a cache env when loading the mock too or something.
In the meantime, I recommend staying on the released version of httr2, which doesn't have this issue.
Is this occurring on anyone else's side? I have
cache = <environment>
just near the end of my mock file. If I replace it withrlang::caller_env()
, then the file can be sourced and a test will pass.End of my mock file:
cache = <environment>, class = "httr2_response")