Commit f4a2b58d authored by Tiago's avatar Tiago
Browse files

fix: do not accidentally mark requests for resend on http2 error

this was too close to the spec, but if last stream id is 0, then all inflight requests would be resent, even in the case of an error which isn't recoverable
parent 96968cf4
Loading
Loading
Loading
Loading
+7 −3
Changes for lib/httpx/connection/http2.rb: 7 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -25,14 +25,18 @@ module HTTPX
    class GoawayError < Error
      UNRECOVERABLE_ERRORS = %i[settings_timeout inadequate_security].freeze

      attr_reader :last_stream_id

      def initialize(code, last_stream_id)
        @code = code
        @last_stream_id = last_stream_id
        super(0, code)
      end

      def last_stream_id
        return Float::INFINITY if unrecoverable?

        @last_stream_id
      end

      def unrecoverable?
        UNRECOVERABLE_ERRORS.include?(@code)
      end
@@ -165,7 +169,7 @@ module HTTPX
    end

    def handle_error(ex, request = nil)
      last_stream_id = 0
      last_stream_id = Float::INFINITY
      case ex
      when OperationTimeoutError
        if !@handshake_completed && @connection.state != :closed
+2 −2
Changes for sig/connection/http2.rbs: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -118,12 +118,12 @@ module HTTPX
    class GoawayError < Error
      UNRECOVERABLE_ERRORS: Array[Symbol]

      attr_reader last_stream_id: Integer

      @code: Symbol

      def initialize: (Symbol code, Integer last_stream_id) -> void

      def last_stream_id: () -> Numeric

      def unrecoverable?: () -> bool
    end