Skip to content

Conversation

@shikokuchuo
Copy link
Member

In our poller, we can replace a usage of tryCatch() with withCallingHandlers(), as we just need to enact a side-effect and let the error percolate up to a tryCatch already established within promises::promise() from where it's called.

There's always a benefit to avoiding tryCatch:

bench::mark(
  withCallingHandlers({}, error = identity),
  tryCatch({}, error = identity)
)
#> # A tibble: 2 × 6
#>   expression                            min  median `itr/sec` mem_alloc `gc/sec`
#>   <bch:expr>                       <bch:tm> <bch:t>     <dbl> <bch:byt>    <dbl>
#> 1 withCallingHandlers({ }, error …    410ns   492ns  1572514.        0B    157. 
#> 2 tryCatch({ }, error = identity)    1.35µs   1.6µs   605433.        0B     60.5

Created on 2025-10-24 with reprex v2.1.1

@shikokuchuo shikokuchuo merged commit d5e64e6 into main Oct 24, 2025
13 checks passed
@shikokuchuo shikokuchuo deleted the req-promise branch October 24, 2025 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants