| Puppet may fail to reuse a previously cached connection under the following conditions: 1. It uses the new HTTP client 2. The previous request was kept alive (the server didn't send Connection: close) 3. The server closes the connection between the time that the client caches it and when the client tries to reuse it. Puppet will report that the connection was "interrupted after 0.001 seconds". The issue occurs because puppet's HTTP client makes a non-local return from the block passed to Net::HTTP#request. As a result the Net::HTTP#end_transport method is never called, which is what sets last_communication to the current timestamp. https://github.com/ruby/ruby/blob/v2_5_7/lib/net/http.rb#L1567 The next time Net::HTTP#request is called, the client's side of the socket is still open and it interprets the nil last_communication value to mean "we've never used this connection before", so it skips the call to Net::HTTP#connect. https://github.com/ruby/ruby/blob/v2_5_7/lib/net/http.rb#L1537-L1546 But as soon as it tries to write the request and read the response, EOFError is raised. |