fix(tests): address recurring flaky failures in subscription-replay, MQTT, and multi-threaded suites#654
Merged
Merged
Conversation
…lay, MQTT, and multi-threaded suites - subscriptionReplay race-condition tests: the collect() quiet-period timer could expire before in-flight writes committed, silently dropping events. Switch to attach-listener- first then await-writes then fixed-drain pattern so all committed events are captured. - MQTT mTLS tests: authorised client connect was missing rejectUnauthorized:false, causing intermittent "self-signed certificate in certificate chain" failures on loaded runners. The tests exercise server-side mTLS (server rejects clients without a cert), not client-side server-cert validation. Add explicit per-test timeout (20 s) and internal 15 s reject path to the QoS=1 durable-session reconnect test. - multi-threaded cache test: assertions targeted specific IDs whose write counts were sensitive to the seeded PRNG's non-uniform distribution. Aggregate across all IDs 20-29 so no single ID's count can cause a false failure. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
|
Reviewed; no blockers found. |
cb1kenobi
approved these changes
May 22, 2026
Replace shared-resolver pattern with ws.once() so each message handler is self-contained; also close the msgpack WebSocket after its test to avoid leaking connections. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
collect()'s quiet-period timer was used to gather events while writes were still in flight. If a write committed after the silence window the event was silently dropped. Replaced with: attach listener → await all writes → fixed drain.rejectUnauthorized: false; Node's TLS was rejecting the server's self-signed cert even when the CA was provided, causing intermittent handshake failures. The test's goal is server-side mTLS (server rejects clients without a cert), not client-side server-cert validation.this.timeout(20000)and an internal 15 s reject path.'24','25') whose write counts are sensitive to the seeded PRNG's non-uniform distribution. Switched to aggregate across all IDs 20–29.Context
These tests have caused ~5 of the last 16 main-branch CI runs to fail (31% failure rate). All failures were confirmed intermittent (different test/different commit each time), and the root causes above explain why they are load/timing/PRNG sensitive.
Changes are test-only, zero production-code risk.
Attention
delay(200/300)drain periods in the subscription-replay fixes are empirical. If they still flake on very slow runners they could be bumped further, but the cross-model review ran the suite and confirmed they pass reliably.rejectUnauthorized: falsechange means the client no longer validates the server cert in these tests. This is appropriate for an internal test scenario but worth noting if these tests are ever repurposed.🤖 Generated with Claude Code — reviewed by agy (Gemini)