Repository navigation
Guard Proxy#stop against already-stopped EventMachine reactor - #359
Merged
ronwsmith merged 2 commits intoMar 3, 2026
Merged
Conversation
When EventMachine has already stopped (e.g. in RSpec after(:suite)), calling EM.get_sockname or EM.stop raises RuntimeError: eventmachine not initialized. Add EM.reactor_running? check to prevent this. Fixes oesmith#253
Collaborator
|
@jeremyjbarth thanks for the contribution! I don't have time to cut a new version right now but I will merge it so you can get off your fork. I'll report back with a new version soon. |
Collaborator
|
@jeremyjbarth this has been released as 4.0.4: https://rubygems.org/gems/puffing-billy/versions/4.0.4 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
EM.reactor_running?guard inProxy#stopto preventRuntimeError: eventmachine not initializedwhen the reactor has already stoppedProblem
When EventMachine has already stopped (e.g. during RSpec
after(:suite)teardown), callingEM.get_sockname(viaport) orEM.stopraisesRuntimeError: eventmachine not initialized. This causes test suites to exit non-zero despite all tests passing ("1 error occurred outside of examples").Solution
The existing
@signature.nil?check only guards against a proxy that was never started. It doesn't cover the case where EventMachine's reactor loop has already been shut down by another mechanism.Fixes #253
Verification
bundle exec rspec spec/lib/proxy_spec.rb— all examples pass, 0 failureseventmachine not initializedcrash in a production Rails app with 935+ messaging specs using puffing-billy 4.0.0