bblimke/webmock · error · IOError

HTTP session already opened

Error message

HTTP session already opened

What it means

Error "HTTP session already opened" thrown in bblimke/webmock.

Source

Thrown at lib/webmock/http_lib_adapters/net_http.rb:125

            super_with_after_request = lambda {
              response = super(request, nil, &nil)
              after_request.call(response)
            }
            if started?
              ensure_actual_connection
              super_with_after_request.call
            else
              start_with_connect {
                super_with_after_request.call
              }
            end
          else
            raise WebMock::NetConnectNotAllowedError.new(request_signature)
          end
        end

        def start_without_connect
          raise IOError, 'HTTP session already opened' if @started
          if block_given?
            begin
              @socket = Net::HTTP.socket_type.new
              @started = true
              return yield(self)
            ensure
              do_finish
            end
          end
          @socket = Net::HTTP.socket_type.new
          @started = true
          self
        end


        def ensure_actual_connection
          if @socket.is_a?(StubSocket)
            @socket&.close

View on GitHub (pinned to b187df8827)

When it happens

Trigger: Thrown at lib/webmock/http_lib_adapters/net_http.rb:125 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of bblimke/webmock@b187df8827 (2026-08-23). Data as JSON: /api/errors/08e5b593b8e444b2. Report an issue: GitHub.