Dev.to
7/19/2026

The bug that only showed up because my test was too fast
Short summary
A debugging story where a Testcontainers wait strategy based on Keycloak's log output caused intermittent connection-reset failures because the log line appears before the HTTP listener is ready. The fix: switch from Wait.forLogMessage to Wait.forHttp polling the actual endpoint. The broader lesson is to wait on the side effect you depend on, not a stated intention.
- •Log-message wait strategies can pass before the service accepts connections
- •Fix: use Wait.forHttp with status code polling instead of log matching
- •General principle: wait on actual side effects, not stated intentions
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



