Skip to content

Commit 08c232a

Browse files
committed
Remove connection-aborting from cancel
1 parent 128c2fe commit 08c232a

4 files changed

Lines changed: 3 additions & 186 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,15 @@ All methods are available on both `Wreq` (module-level) and `Wreq::Client` (inst
116116

117117
### Cancelling Requests
118118

119-
Call `cancel` on a client to abort all in-flight requests and close their underlying connections immediately:
119+
Call `cancel` on a client to interrupt all in-flight requests immediately:
120120

121121
```ruby
122122
client = Wreq::Client.new
123123

124124
# From another thread:
125125
t = Thread.new { client.get("https://slow.example.com/big-download") }
126126
sleep 1
127-
client.cancel # all in-flight requests return with "request interrupted" error
127+
client.cancel # all in-flight requests raise Wreq::Error with "request interrupted"
128128
```
129129

130130
### Per-Request Options

ext/wreq_rb/src/client.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,6 @@ impl Client {
388388
old
389389
};
390390
old_token.cancel();
391-
self.inner.cancel_connections();
392391
}
393392

394393
fn execute_method(&self, method_str: &str, args: &[Value]) -> Result<Response, magnus::Error> {

patches/0002-add-cancel-connections.patch

Lines changed: 0 additions & 181 deletions
This file was deleted.

test/thread_safety_test.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ def test_cancel_aborts_h2_connection
179179

180180
sleep 0.5
181181

182-
# cancel() should unblock the in-flight select! immediately.
183182
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
184183
client.cancel
185184
elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
@@ -194,7 +193,7 @@ def test_cancel_aborts_h2_connection
194193
assert_kind_of Wreq::Error, error
195194
assert_match "request interrupted", error.message
196195

197-
# Client should still be usable — a new H2 connection is established.
196+
# Client should still be usable — a new connection is established.
198197
resp = client.get("https://httpbin.org/get")
199198
assert_equal 200, resp.status
200199
end

0 commit comments

Comments
 (0)