Testcontainers is a NodeJS library that supports tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
Expected Behaviour
Testcontainers will try to create new Reaper instance after failed connection and the Reaper is actualy down.
Actual Behaviour
There is race condition, a very small chance but still affects us once in ~10 test suites, when uping and downing testcontainers in sequence for many microsevices tests.
After every test suite it is very likely for next suite setting up the test containers to reuse reaper container instance. When it happens, sometimes I get "Failed to connect to Reaper" message and it fails.
Expected Behaviour Testcontainers will try to create new Reaper instance after failed connection and the Reaper is actualy down.
Actual Behaviour There is race condition, a very small chance but still affects us once in ~10 test suites, when uping and downing testcontainers in sequence for many microsevices tests.
After every test suite it is very likely for next suite setting up the test containers to reuse reaper container instance. When it happens, sometimes I get "Failed to connect to Reaper" message and it fails.
I think there is small window when testcontainers check if current reaper exists but it is about to shutdown so we cannot connect to it. https://github.com/testcontainers/testcontainers-node/blob/main/packages/testcontainers/src/reaper/reaper.ts#L30-L36
Next suite after the failed one starts with no problems with new Reaper. Testcontainer Logs Previous test suite:
Failed test suite:
Suite after the failed one:
Environment Information