cutoff 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ccf20a5afa9e52d5c638e5e72edfa1395375701b31525868ab354d036d6593a5
4
- data.tar.gz: 83f27ac46d53346b3fa5c9b07644dacb3ce058a78d7bd0e07a72e0eb4b291874
3
+ metadata.gz: 62b041df9110341cc0f55dc67e59098c03caa41f96661bd95a73689e0e508606
4
+ data.tar.gz: c61f6dd25c2781924d9f98bf20ca1deedc701f2d4aae143dad97eae987006a47
5
5
  SHA512:
6
- metadata.gz: 5b13ffe6962c36d49aff8969bc1ca23e8e0173885505556d945dd19593b815261fc07202d3fa75d83433d3c6ad831645bcdaaf79e5a06785e1a4dc9aeceea955
7
- data.tar.gz: 165328cd0c983b3ec1b9007c0a4e17bd4e66b3dd4683f4a760e7374ec1c563caff1ffcd9dfe8653e8945da92764d110a7fb3ef7d66011d56d1f3f91cda7d4983
6
+ metadata.gz: 853b7822a150ea5c55b345694919299a839f06d8f414dde5fd285d30789a3a6f4e3da234dc32fafd6411b358827ee0f25184da28fff1140d5d86aca4df7f286c
7
+ data.tar.gz: df37414f0271365e2fdb0adfe5e8a20e805b353f6c37d8b391271edc1ddf4f96a82cf7c340d59ca56c56b722a9873f5031d84f5b6eba5e532a54baa363da1dbd
data/CHANGELOG.md CHANGED
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.1.0] - 2026-05-12
11
+
12
+ ### Fixed
13
+
14
+ - Net::HTTP patch now also re-applies on `begin_transport`, so internal retries
15
+ (Net::HTTP retries idempotent requests once by default on transient errors
16
+ like Net::ReadTimeout) respect the cutoff instead of silently doubling the
17
+ effective deadline.
18
+
10
19
  ## [1.0.0] - 2026-05-12
11
20
 
12
21
  This release marks Cutoff's API as stable. There are no behavior changes
@@ -98,7 +107,8 @@ to `Timeout::Error`. `CutoffError` changes from a class to a module.
98
107
  - Cutoff class
99
108
  - Mysql2 patch
100
109
 
101
- [Unreleased]: https://github.com/justinhoward/cutoff/compare/v1.0.0...HEAD
110
+ [Unreleased]: https://github.com/justinhoward/cutoff/compare/v1.1.0...HEAD
111
+ [1.1.0]: https://github.com/justinhoward/cutoff/compare/v1.0.0...v1.1.0
102
112
  [1.0.0]: https://github.com/justinhoward/cutoff/compare/v0.5.2...v1.0.0
103
113
  [0.5.2]: https://github.com/justinhoward/cutoff/compare/v0.5.1...v0.5.2
104
114
  [0.5.1]: https://github.com/justinhoward/cutoff/compare/v0.5.0...v0.5.1
@@ -25,22 +25,43 @@ class Cutoff
25
25
  end
26
26
 
27
27
  # Same as the original start, but adds a checkpoint for starting HTTP
28
- # requests and sets network timeouts to the remaining time
28
+ # requests and sets network timeouts to the remaining time.
29
+ #
30
+ # Also applies the same logic to begin_transport, which is called on
31
+ # every HTTP attempt including internal retries. Net::HTTP#transport_request
32
+ # silently retries idempotent requests (GET, HEAD, PUT, DELETE, OPTIONS,
33
+ # TRACE) up to max_retries (default 1) on transient errors like
34
+ # Net::ReadTimeout. Without re-applying the cutoff in begin_transport,
35
+ # the retry path goes through #connect (not #start), reuses the original
36
+ # read_timeout, and effectively doubles the deadline you set.
29
37
  #
30
38
  # @method start
39
+ # @method begin_transport
31
40
  # @see Net::HTTP#start
41
+ # @see Net::HTTP#begin_transport
32
42
  module_eval(<<~RUBY, __FILE__, __LINE__ + 1)
33
43
  def start
34
- if (cutoff = Cutoff.current) && cutoff.selected?(:net_http)
35
- remaining = cutoff.seconds_remaining
36
- #{gen_timeout_method('open_timeout')}
37
- #{gen_timeout_method('read_timeout')}
38
- #{gen_timeout_method('write_timeout') if use_write_timeout?}
39
- #{gen_timeout_method('continue_timeout')}
40
- Cutoff.checkpoint!(:net_http)
41
- end
44
+ _cutoff_apply_to_net_http
42
45
  super
43
46
  end
47
+
48
+ def begin_transport(req)
49
+ _cutoff_apply_to_net_http
50
+ super
51
+ end
52
+
53
+ private
54
+
55
+ def _cutoff_apply_to_net_http
56
+ return unless (cutoff = Cutoff.current) && cutoff.selected?(:net_http)
57
+
58
+ remaining = cutoff.seconds_remaining
59
+ #{gen_timeout_method('open_timeout')}
60
+ #{gen_timeout_method('read_timeout')}
61
+ #{gen_timeout_method('write_timeout') if use_write_timeout?}
62
+ #{gen_timeout_method('continue_timeout')}
63
+ Cutoff.checkpoint!(:net_http)
64
+ end
44
65
  RUBY
45
66
  end
46
67
  end
@@ -3,6 +3,6 @@
3
3
  class Cutoff
4
4
  # @return [Gem::Version] The current version of the cutoff gem
5
5
  def self.version
6
- Gem::Version.new('1.0.0')
6
+ Gem::Version.new('1.1.0')
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cutoff
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Howard
@@ -84,7 +84,7 @@ licenses:
84
84
  - MIT
85
85
  metadata:
86
86
  changelog_uri: https://github.com/justinhoward/cutoff/blob/master/CHANGELOG.md
87
- documentation_uri: https://www.rubydoc.info/gems/cutoff/1.0.0
87
+ documentation_uri: https://www.rubydoc.info/gems/cutoff/1.1.0
88
88
  rubygems_mfa_required: 'true'
89
89
  post_install_message:
90
90
  rdoc_options: []