Skip to content

Deprecate timeout option for 3.8.0#135

Merged
kamui merged 8 commits into
mainfrom
deprecate-timeout
May 27, 2026
Merged

Deprecate timeout option for 3.8.0#135
kamui merged 8 commits into
mainfrom
deprecate-timeout

Conversation

@kamui
Copy link
Copy Markdown
Owner

@kamui kamui commented May 27, 2026

Summary

  • Deprecates non-nil timeout: usage while preserving existing 3.x runtime behavior. Related: Timeout::timeout is inherently unsafe #96
  • Adds coverage for Config, Retriable.retriable, with_override, and configured timeout warnings, including avoiding duplicate warnings.
  • Bumps the gem to 3.8.0 and documents the migration path before Retriable 4.0 removes timeout:.

Test Plan

  • bundle exec rspec (139 examples, 0 failures)
  • bundle exec rubocop (same 5 pre-existing gemspec offenses as baseline; no new offenses)
  • bundle exec ruby -Ilib -r retriable -e 'Retriable.retriable(timeout: 1) { :ok }'
  • bundle exec ruby -Ilib -r retriable -e 'Retriable.retriable { :ok }'
  • gem build retriable.gemspec && rm retriable-3.8.0.gem

kamui and others added 8 commits May 26, 2026 22:46
Reroute the timeout: deprecation through a Gem::Deprecate-style
once-per-process gate. The previous helper checked Warning[:deprecated]
and fell back to a plain Kernel.warn when deprecation warnings were
disabled, which inverted user intent (silencing the standard channel
caused us to emit anyway).

- Config tracks emission state class-side and short-circuits on
  Gem::Deprecate.skip, so Gem::Deprecate.skip_during { ... } silences
  the warning for callers and tests.
- Kernel.warn is called without category: :deprecated because
  Warning[:deprecated] defaults to false in Ruby 3.x and would hide
  the notice from end users; Gem::Deprecate itself plain-warns for
  the same reason.
- Retriable.retriable validates the local config unconditionally
  again now that double-validation no longer double-warns; the
  previous dedup branch is removed and the comment is no longer
  misleading.
- Spec helper resets the flag before each example; new specs cover
  once-per-process behavior, Gem::Deprecate.skip_during silencing,
  and re-arming after a skipped block.
- README/CHANGELOG document once-per-process emission, the
  skip_during escape hatch, and that wrapping the retried block in
  Timeout.timeout(5) preserves per-try semantics (use
  max_elapsed_time: for an overall cap).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Switch the timeout: deprecation notice from a plain Kernel.warn to
Kernel.warn(..., category: :deprecated) on Rubies that support the
keyword (2.7+), and drop the bespoke Gem::Deprecate.skip escape hatch.

This restores the standard Ruby deprecation controls:

  * Warning[:deprecated] = false silences the warning.
  * ruby -W:no-deprecated silences the warning.
  * Overriding Warning.warn lets callers filter it.

Older Rubies (2.3-2.6) that lack the category kwarg keep the previous
plain Kernel.warn behavior.

The once-per-process gate is preserved, but it now only fires when the
warning is actually emitted. If the category is muted, the warner stays
armed, so a later call with deprecation warnings re-enabled still
surfaces the notice.
@kamui kamui merged commit 3c6ffa7 into main May 27, 2026
13 checks passed
@kamui kamui deleted the deprecate-timeout branch May 27, 2026 04:00
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.

1 participant