# Try not capturing an Net:HTTP#post error

**URL:** <https://discourse.hanakai.org/t/try-not-capturing-an-net-http-post-error/1550>\
**Category:** issues\
**Created:** [September 25, 2026, 7:45pm UTC](https://discourse.hanakai.org/t/try-not-capturing-an-net-http-post-error/1550 "2026-09-25T19:45:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![esparta](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/esparta/32/1201_2.png) [@esparta](https://discourse.hanakai.org/u/esparta)\
**Post date:** [September 25, 2026, 7:45pm UTC](https://discourse.hanakai.org/t/try-not-capturing-an-net-http-post-error/1550/1 "2026-09-25T19:45:43Z")

</div>

Hi

I have a very tiny wrapper around a internal tool, communicating via HTTP

```auto
def post(url:)                                                                  
  payload = { url: url }.to_json                                               
                                                                               
  Try do                                                                        
    uri = URI(settings.url)                                
    client = Net::HTTP.new(uri.host, uri.port).tap do |http|                    
      http.use_ssl = true                                                      
      http.read_timeout = 1 # in seconds                                       
      http.open_timeout = 1                                              
      http.write_timeout = 1                                                                                                                            
    end
                                                                                                                                             
    client.post('/v1/link', payload, HEADERS)                                  
  end.to_result
end 

```

It works fine in the specs where I do simulate the timeout either via `webmock` or using `rspec` spies, but in production the Try block seems like not working according to Sentry:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/hanamirb/original/2X/f/fd1e421a7f3d65ab0384b1f794d780485706ffea.png)

something I noticed is the description:

> Crashed in non-app:
> 
> `net/protocol.rb` in `rbuf_fill`

is there something I can do about it?

---

<div class="post-metadata">

**Author:** ![alassek](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/alassek/32/532_2.png) [@alassek](https://discourse.hanakai.org/u/alassek)\
**Post date:** [September 25, 2026, 10:39pm UTC](https://discourse.hanakai.org/t/try-not-capturing-an-net-http-post-error/1550/2 "2026-09-25T22:39:32Z")

</div>

I’m having difficulty reproducing this. Are you able to write a minimal repro?

```ruby
irb(main):004> Dry::Monads::Try { raise Net::ReadTimeout }.to_result
=> Failure(#<Net::ReadTimeout: Net::ReadTimeout>)

```

---

<div class="post-metadata">

**Author:** ![esparta](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.hanakai.org/esparta/32/1201_2.png) [@esparta](https://discourse.hanakai.org/u/esparta)\
**Post date:** [September 26, 2026, 12:07am UTC](https://discourse.hanakai.org/t/try-not-capturing-an-net-http-post-error/1550/3 "2026-09-26T00:07:12Z")

</div>

> [@alassek](#):
>
> Are you able to write a minimal repro?

No, I’m not able to reproduce it

All my test just pass, I tried what you did, making webmock to raise the error, and nothing else seems to catch it. Also tried overwriting `Net::HTTP#post` and still good:

```

```auto
Net::HTTP.prepend(Module.new { def post(*) = raise(Net::ReadTimeout) })

Theclass.new.call(url: 'https://example.com')
# => Failure(#<Net::ReadTimeout: Net::ReadTimeout>)

```
