Skip to content

feat: Add thread reader to client #52

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

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