Module: Capybara::Lightpanda::Utils::Attempt
- Defined in:
- lib/capybara/lightpanda/utils/attempt.rb
Overview
Generic retry helper for transient CDP-class errors. Mirrors ferrum’s Utils::Attempt — extracted so callsites don’t have to rebuild the rescue/sleep loop. Default ‘max` and `wait` match ferrum’s INTERMITTENT_ATTEMPTS / INTERMITTENT_SLEEP so behavior is predictable across the two ecosystems.
Constant Summary collapse
- INTERMITTENT_ATTEMPTS =
6- INTERMITTENT_SLEEP =
0.1
Class Method Summary collapse
Class Method Details
.with_retry(errors:, max: INTERMITTENT_ATTEMPTS, wait: INTERMITTENT_SLEEP) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/capybara/lightpanda/utils/attempt.rb', line 15 def self.with_retry(errors:, max: INTERMITTENT_ATTEMPTS, wait: INTERMITTENT_SLEEP) attempts = 0 begin yield rescue *Array(errors) attempts += 1 raise if attempts >= max sleep wait retry end end |