falcon 0.55.2 → 0.55.4

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: 3e901867477864a82832904cbaa1662105e6dce12190e057d457a666fa3dfe42
4
- data.tar.gz: 523e181a6685bfe398bc5630076ab8e76642bf47181d4e20c62192813f121712
3
+ metadata.gz: 518acbb2388840608c7abc42e802372d5b8cf547d0928a0164afc5bdd3aa7590
4
+ data.tar.gz: 9d37e38f1c95e19fa11a34c7ccebab765820401a48bea7e97b6a9ecf7e0c36d5
5
5
  SHA512:
6
- metadata.gz: 0eb64a874478507caeafefb4c83b108cfa7b00326cf69ce7581ab534e9466048dea1572b66044f06ee19b21998fafad32cf5de3ea050f6ae0f32b1743424ef2e
7
- data.tar.gz: 3f041a4ebdf07b1063373a27e7151b4f8380f4f440b34a773f27b0b6761d64f721209c5a7d2366f1210e1be1d3042d1e8bed117a77a7ce81d9335274636fe656
6
+ metadata.gz: 05ae47c057c66f6a89e84d2f46a2a4db66109716a1035af63bfd0e2db4272d51a1e6702bf7f915a32b1f9479c991ca7de622d7ed96ac1ddfa7c6e234a866299b
7
+ data.tar.gz: 4ceeb8958477cff0ffc308ea911e7844bebb6343cf464a20e35e749098a104cf2f807f92d56fb891eeb4f2135cbec638b1518b7b7362ee926658250f19d09898
checksums.yaml.gz.sig CHANGED
Binary file
@@ -11,10 +11,13 @@ module Falcon
11
11
  # Wraps a response body and decrements a metric after the body is closed.
12
12
  #
13
13
  # Runs close on the underlying body first (which invokes rack.response_finished),
14
- # then decrements the metric. Use this so requests_active stays elevated until
15
- # the request is fully finished (including response_finished callbacks).
14
+ # then decrements the metric, even if closing raises. Use this so requests_active
15
+ # stays elevated until the request is fully finished (including response_finished
16
+ # callbacks), without leaking if close reports an error.
16
17
  class RequestFinished < Protocol::HTTP::Body::Wrapper
17
- # Wrap a response body with a metric. If the body is nil or empty, decrements immediately.
18
+ # Wrap a response body with a metric.
19
+ #
20
+ # Expects the caller to have incremented `requests_active` beforehand. If the body is not wrapped (nil or empty message/body, or an error while assigning the wrapper), the `ensure` block decrements once. When wrapped, the metric is decremented in {#close}.
18
21
  #
19
22
  # @parameter message [Protocol::HTTP::Response] The response whose body to wrap.
20
23
  # @parameter metric [Async::Utilization::Metric] The metric to decrement when the body is closed.
@@ -29,6 +32,8 @@ module Falcon
29
32
  message
30
33
  end
31
34
 
35
+ # Initialize the wrapper.
36
+ #
32
37
  # @parameter body [Protocol::HTTP::Body::Readable] The body to wrap.
33
38
  # @parameter metric [Async::Utilization::Metric] The metric to decrement on close.
34
39
  def initialize(body, metric)
@@ -52,7 +57,7 @@ module Falcon
52
57
  # @parameter error [Exception, nil] Optional error that caused the close.
53
58
  def close(error = nil)
54
59
  super
55
-
60
+ ensure
56
61
  @metric&.decrement
57
62
  @metric = nil
58
63
  end
data/lib/falcon/server.rb CHANGED
@@ -69,10 +69,22 @@ module Falcon
69
69
  # Body::RequestFinished wrapper runs the decrement after the body closes,
70
70
  # so response_finished callbacks are counted as active.
71
71
  def call(...)
72
+ decrement = false
73
+
72
74
  @requests_total_metric.increment
73
75
  @requests_active_metric.increment
76
+ decrement = true
77
+
78
+ # Roll back `requests_active` unless the full `super` + wrap path completes. Covers
79
+ # `super` raising before `wrap` runs, errors inside `wrap`, and other abnormal exits.
80
+ response = Body::RequestFinished.wrap(super, @requests_active_metric)
81
+ decrement = false
74
82
 
75
- return Body::RequestFinished.wrap(super, @requests_active_metric)
83
+ return response
84
+ ensure
85
+ if decrement
86
+ @requests_active_metric.decrement
87
+ end
76
88
  end
77
89
 
78
90
  # Generates a human-readable string representing the current statistics.
@@ -5,5 +5,5 @@
5
5
 
6
6
  # @namespace
7
7
  module Falcon
8
- VERSION = "0.55.2"
8
+ VERSION = "0.55.4"
9
9
  end
data/readme.md CHANGED
@@ -47,9 +47,17 @@ Please see the [project documentation](https://socketry.github.io/falcon/) for m
47
47
 
48
48
  Please see the [project releases](https://socketry.github.io/falcon/releases/index) for all releases.
49
49
 
50
+ ### v0.55.4
51
+
52
+ - Ensure `requests_active` is decremented if closing the response body raises.
53
+
54
+ ### v0.55.3
55
+
56
+ - Decrement `requests_active` in `Falcon::Server#call` when `super` or `Falcon::Body::RequestFinished.wrap` raises, so utilization metrics are not leaked on error paths.
57
+
50
58
  ### v0.55.2
51
59
 
52
- - Remove unnecessary require for `async/service/supervisor/supervised`."
60
+ - Remove unnecessary require for `async/service/supervisor/supervised`.
53
61
 
54
62
  ### v0.55.1
55
63
 
@@ -87,15 +95,6 @@ Please see the [project releases](https://socketry.github.io/falcon/releases/ind
87
95
  - Introduce <code class="language-ruby">Falcon::Environment::Server\#make\_server</code> which gives you full control over the server creation process.
88
96
  - [Introduce `Async::Container::Supervisor`.](https://socketry.github.io/falcon/releases/index#introduce-async::container::supervisor.)
89
97
 
90
- ### v0.50.0
91
-
92
- - Add <code class="language-ruby">Falcon::Environment::Server\#endpoint\_options</code> to allow configuration of the endpoint options more easily.
93
-
94
- ### v0.49.0
95
-
96
- - [Falcon Server Container Health Checks](https://socketry.github.io/falcon/releases/index#falcon-server-container-health-checks)
97
- - [Falcon Server Process Title](https://socketry.github.io/falcon/releases/index#falcon-server-process-title)
98
-
99
98
  ## Contributing
100
99
 
101
100
  We welcome contributions to this project.
data/releases.md CHANGED
@@ -1,8 +1,16 @@
1
1
  # Releases
2
2
 
3
+ ## v0.55.4
4
+
5
+ - Ensure `requests_active` is decremented if closing the response body raises.
6
+
7
+ ## v0.55.3
8
+
9
+ - Decrement `requests_active` in `Falcon::Server#call` when `super` or `Falcon::Body::RequestFinished.wrap` raises, so utilization metrics are not leaked on error paths.
10
+
3
11
  ## v0.55.2
4
12
 
5
- - Remove unnecessary require for `async/service/supervisor/supervised`."
13
+ - Remove unnecessary require for `async/service/supervisor/supervised`.
6
14
 
7
15
  ## v0.55.1
8
16
 
data.tar.gz.sig CHANGED
@@ -1 +1,5 @@
1
- q,4��_�:�=�"��ߙ����t!&sל�c\�q�bN�gL�>>S�}!!�Db�Y�,w����kC����U���������+'�'��[x٥�L���!�+�L��f��&`Go���XZ����^p�G`��
1
+ ����ҳƇJ�si
2
+ 5��6={К+�bV�_G8l�q��|��\E�����a�
3
+ �G�t� \�t����W�rn��Q�S�p����w������]ͤe�g����Ŗ��l�X��
4
+ E���nb[����Zd�|%�ަ�+�s���X6�$�ku�:��` ���E�slnq��!�XQOmNL���k(��m3�aQA����ݳ��J�T�@�QT�,�LJ�}{��vç���һS��t�J��hEd��=�\����ɳN�|��X� _{�<��u�}�� ���.�T�OC7�̕]���9�νrR�Ѹ/)8�=���� �kt��D��_�w�$&�әhv�r_�
5
+ e�
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: falcon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.55.2
4
+ version: 0.55.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -312,7 +312,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
312
312
  - !ruby/object:Gem::Version
313
313
  version: '0'
314
314
  requirements: []
315
- rubygems_version: 4.0.3
315
+ rubygems_version: 4.0.10
316
316
  specification_version: 4
317
317
  summary: A fast, asynchronous, rack-compatible web server.
318
318
  test_files: []
metadata.gz.sig CHANGED
Binary file