Skip to content

Multiple failures in em_http_request adapter when synchrony is enabled. #1115

Description

@phdavis1027

I wrote the following specs in spec/acceptance/em_http_request/em_http_request_spec.rb, which all failed due to timeout:

      if defined?(EventMachine::Synchrony)
      # ...
                it "should call `headers` before processing stream" do
            stub_request(:get, "www.example.com").to_return(body: "abc", headers: { 'needle': 'found' })
            headers_called = nil
            EM.run do
              EM.add_timer(1) { raise "Timeout: callbacks never fired" }
              fiber = Fiber.new do
                http = EM::HttpRequest.new("http://www.example.com").get
                http.stream { |*|
                  expect(headers_called).to eq('found')
                  EM.stop
                }
                http.headers { |h|
                  expect(headers_called).to be_nil
                  headers_called = h['needle']
                }
              end
              fiber.resume
            end
          end

          it "should call `stream` callback at all" do
            stub_request(:get, "www.example.com").to_return(body: "abc")
            stream_called = false
            EM.run do
              EM.add_timer(1) { EM.stop }
              fiber = Fiber.new do
                http = EM::HttpRequest.new("http://www.example.com").get
                http.stream { |*| stream_called = true }
              end
              fiber.resume
            end
            expect(stream_called).to eq(true)
          end

          it "should call `headers` callback at all" do
            stub_request(:get, "www.example.com").to_return(body: "abc", headers: { "X-DEBUG": "Hello, World!" })
            EM.run do
              EM.add_timer(1) { EM.stop }
              fiber = Fiber.new do
                http = EM::HttpRequest.new("http://www.example.com").get
                http.headers { |h| expect(h['X-DEBUG'].to eq('Hello, World!')) }
              end
              fiber.resume
            end
            expect(stream_called).to eq(true)
          end

I ran them like this:

bundle exec rspec -r em-synchrony spec/acceptance/em_http_request/em_http_request_spec.rb -e "should call"

against tip of master.

Worth noting: when I just cloned the repo fresh and ran bundle exec rspec I got dozens of failures and multiple sluggish tests which together ran so slowly that I could not let them all finish. Don't know why.

I'm on Fedora 42, MRI 3.4.7

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions