Skip to content

Conversation

Exterm1nate
Copy link
Contributor

@Exterm1nate Exterm1nate commented Apr 18, 2025

When stopping the client its thread continues working for some time. This is not a problem in production, but in tests it is. Webmock removes its stub after the test, while the thread is still working, so we sometimes receive such errors:

#<Thread:0x0000761ef6935090@LD/SSEClient /usr/local/bundle/ruby/3.1.0/gems/ld-eventsource-2.2.3/lib/ld-eventsource/client.rb:144 run> terminated with exception (report_on_exception is true):
/usr/local/bundle/ruby/3.1.0/gems/webmock-3.25.1/lib/webmock/http_lib_adapters/http_rb/webmock.rb:63:in `halt': Real HTTP connections are disabled. Unregistered request: GET http://localhost:3003/admin/v1/emails with headers {'Accept'=>'text/event-stream', 'Authorization'=>'Bearer test_key', 'Cache-Control'=>'no-cache', 'Connection'=>'close', 'Host'=>'localhost:3003', 'Last-Event-Id'=>'0', 'User-Agent'=>'ruby-eventsource'} (WebMock::NetConnectNotAllowedError)

This PR adds a reader for thread, so it can be killed after the test example.

subject(:call_method) do
  processor.start
  sleep 0.1
end

after do
  processor.connection.thread&.kill
end

@Exterm1nate Exterm1nate requested a review from a team as a code owner April 18, 2025 07:02
@Exterm1nate Exterm1nate changed the title Add thread reader to client feat: Add thread reader to client Apr 18, 2025
@Exterm1nate
Copy link
Contributor Author

Opened another PR from another branch: #54

Closing this as duplicate.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant