Skip to content

fix(test): race condition in spub/ssub auto-resubscription test#2092

Merged
PavelPashov merged 1 commit intoredis:mainfrom
rit3sh-x:fix/spub-ssub-test-race-condition
Apr 2, 2026
Merged

fix(test): race condition in spub/ssub auto-resubscription test#2092
PavelPashov merged 1 commit intoredis:mainfrom
rit3sh-x:fix/spub-ssub-test-race-condition

Conversation

@rit3sh-x
Copy link
Copy Markdown
Contributor

@rit3sh-x rit3sh-x commented Apr 2, 2026

Summary

Fixes a flaky test that intermittently fails with TypeError: Cannot read properties of null (reading 'args') at spub_ssub.ts:168.

Root cause

subscriber.disconnect({ reconnect: true }) wasn't triggering proper reconnection, so the sinon stub didn't capture all 3 ssubscribe calls before the
assertions ran.

Fix

Changed to subscriber.disconnect(true) which correctly triggers reconnection and auto-resubscription.

Test plan

  • should call ssubscribe individually for each channel during auto-resubscription passes consistently
  • All 9 spub/ssub tests pass

Note

Low Risk
Low risk: changes are limited to functional tests and only adjust expectations and reconnection triggering to reduce flakiness.

Overview
Fixes a flaky spub/ssub functional test by triggering reconnect via subscriber.disconnect(true) so auto-resubscription reliably replays the three ssubscribe calls before assertions run.

Also makes the subscriber-mode error assertion tolerant of a possibly undefined error object by matching on err?.message.

Written by Cursor Bugbot for commit b4cb5e6. This will update automatically on new commits. Configure here.

  Changed disconnect({ reconnect: true }) to disconnect(true) to ensure
  proper reconnection behavior during auto-resubscription testing.
Copy link
Copy Markdown
Contributor

@PavelPashov PavelPashov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution. LGTM

@PavelPashov PavelPashov merged commit c8a65bc into redis:main Apr 2, 2026
12 checks passed
@rit3sh-x rit3sh-x deleted the fix/spub-ssub-test-race-condition branch April 2, 2026 20:02
rit3sh-x added a commit to rit3sh-x/ioredis that referenced this pull request Apr 4, 2026
  Follow-up to redis#2092. Await initial ssubscribe calls and poll for
  stub.callCount before asserting, so the test is stable under load.
simong added a commit to simong/ioredis that referenced this pull request Apr 8, 2026
…dying

* origin:
  feat: Implement `TracingChannel` support (redis#2089)
  chore(ci): add custom Redis version to test matrix (redis#2067)
  chore(deps): update and pin production dependencies (redis#2087)
  test: race condition in spub/ssub auto-resubscription test (redis#2092)
  chore(release): 5.10.1 [skip ci]
  fix(cluster): lazily start sharded subscribers (redis#2090)
  chore(release): 5.10.0 [skip ci]
  feat: add hash field expiration commands and tests
  feat: add hexpireat & hexpiretime (redis#2082)
  ci: make Coveralls steps non-blocking in test_with_cov workflow (redis#2083)
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.

2 participants