Skip to content

Fix flaky Puma plugin tests caused by port collision#733

Open
diogovernier wants to merge 1 commit intorails:mainfrom
diogovernier:fix-flaky-puma-plugin-tests
Open

Fix flaky Puma plugin tests caused by port collision#733
diogovernier wants to merge 1 commit intorails:mainfrom
diogovernier:fix-flaky-puma-plugin-tests

Conversation

@diogovernier
Copy link
Copy Markdown

@diogovernier diogovernier commented Apr 9, 2026

Summary

Related to #602.

Puma plugin tests bind to a hardcoded port (9222). When consecutive tests run, the OS may still hold the previous port in TCP TIME_WAIT state, causing EADDRINUSE that cascades into false test failures.

This replaces the fixed port with dynamic allocation via TCPServer, so each test gets a guaranteed available port.

To be precise, this PR should fix this flaky test, for instance: https://github.com/rails/solid_queue/actions/runs/24190892956/job/70607570480?pr=732

What changed

File Change
test/integration/puma/plugin_testing.rb Replace hardcoded port 9222 with TCPServer.new("127.0.0.1", 0) dynamic allocation

The Puma plugin tests bind to a hardcoded port (9222). When a test
teardown completes and the next test setup starts, the OS may still
hold the port in TCP TIME_WAIT state, causing EADDRINUSE failures
that cascade into nil process lookups and false test failures.

Replace the hardcoded port with a dynamically allocated one via
TCPServer, so each test gets a guaranteed available port.
@diogovernier diogovernier marked this pull request as ready for review April 9, 2026 13:21
@diogovernier diogovernier mentioned this pull request Apr 9, 2026
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