Skip to content

fix(client): stabilize flaky LATENCY LATEST test#3326

Open
nkaradzhov wants to merge 1 commit into
redis:masterfrom
nkaradzhov:fix/flaky-latency-latest
Open

fix(client): stabilize flaky LATENCY LATEST test#3326
nkaradzhov wants to merge 1 commit into
redis:masterfrom
nkaradzhov:fix/flaky-latency-latest

Conversation

@nkaradzhov

@nkaradzhov nkaradzhov commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

This pull request fixes a flaky client.latencyLatest test in packages/client/lib/commands/LATENCY_LATEST.spec.ts.

The bug

The test issued DEBUG SLEEP 1, blocking the server for a full second. Combined with connection setup and the flushAll calls the harness runs before/after each test, this left little headroom under mocha's 2000ms default timeout. On loaded CI runners it intermittently exceeded the timeout:

Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.
  (packages/client/lib/commands/LATENCY_LATEST.spec.ts)

The fix

Halve the sleep to 0.5 (500ms). It still comfortably exceeds the latency-monitor-threshold of 100ms, so a latency event is still recorded and the assertions remain meaningful, while roughly doubling the non-sleep budget under the 2000ms timeout. This matches the pattern in sibling specs (LATENCY_RESET.spec.ts uses DEBUG SLEEP 0.1 against a 1ms threshold).

Locally the test now completes in ~550ms.

🤖 Generated with Claude Code


Note

Low Risk
Test-only timing tweak with no production or client API changes.

Overview
Reduces the Redis DEBUG SLEEP duration in the client.latencyLatest integration test from 1s to 0.5s so the case stays under Mocha’s default 2000ms timeout on slow CI, where harness setup and flushAll left little margin after a full-second block.

The 100ms latency-monitor-threshold is unchanged, so 500ms sleep still triggers latency events and the existing shape assertions stay valid—aligned with shorter sleeps used in other LATENCY specs (e.g. LATENCY_RESET).

Reviewed by Cursor Bugbot for commit c6f4f68. Bugbot is set up for automated code reviews on this repo. Configure here.

The `client.latencyLatest` test blocked the server for a full second via
`DEBUG SLEEP 1`, leaving little headroom under mocha's 2000ms default
timeout once connection setup and flushAll overhead were added. On loaded
CI runners the test intermittently timed out.

Halve the sleep to `0.5` (500ms), which still comfortably exceeds the
100ms `latency-monitor-threshold` so a latency event is recorded, while
roughly doubling the non-sleep budget under the timeout.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nkaradzhov nkaradzhov marked this pull request as ready for review July 9, 2026 08:06
@nkaradzhov nkaradzhov requested a review from PavelPashov July 9, 2026 08:06
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