Skip to content

fix: Clean up DDP publication close listeners - #42032

Open
vasiliy-grinko wants to merge 1 commit into
RocketChat:developfrom
vasiliy-grinko:fix/ddp-publication-close-listener
Open

fix: Clean up DDP publication close listeners#42032
vasiliy-grinko wants to merge 1 commit into
RocketChat:developfrom
vasiliy-grinko:fix/ddp-publication-close-listener

Conversation

@vasiliy-grinko

@vasiliy-grinko vasiliy-grinko commented Sep 2, 2026

Copy link
Copy Markdown

Proposed changes (including videos or screenshots)

Remove a DDP publication's client close listener when the publication stops. Previously, stopped publications were removed from client.subscriptions, but their one-time listeners remained attached until the WebSocket closed.

This adds regression coverage for:

  • explicit publication stop cleanup;
  • more than 50 sequential subscribe/stop cycles;
  • stopping active publications when the client closes.

Issue(s)

Closes #42031

Steps to test or reproduce

yarn workspace @rocket.chat/ddp-streamer test Publication.spec.ts

Without the fix, the explicit stop and subscription churn tests retain client close listeners. With the fix, the listener count returns to zero while the existing client-close behavior remains intact.

Further comments

The runtime regression scenario was also verified with the repository's required Node.js 22.22.3. Full Jest and lint execution was not available in the local sparse checkout because Yarn validates workspace manifests outside the checked-out paths; the test is included for CI execution.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes

    • Improved cleanup when a client connection closes or a publication is manually stopped.
    • Prevented lingering close listeners and subscription entries during repeated start/stop activity.
  • Tests

    • Added coverage for listener cleanup, subscription churn, and automatic stopping when the client disconnects.

@dionisio-bot

dionisio-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot

changeset-bot Bot commented Sep 2, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 6537dbc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 4c13ff8f-b504-42fb-ae65-0a849962713b

📥 Commits

Reviewing files that changed from the base of the PR and between 75e5b93 and 6537dbc.

📒 Files selected for processing (2)
  • ee/apps/ddp-streamer/src/Publication.spec.ts
  • ee/apps/ddp-streamer/src/Publication.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: cubic · AI code reviewer
🧰 Additional context used
📓 Path-based instructions (2)
Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests Avoid code comments in the implementation

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

Files:

  • ee/apps/ddp-streamer/src/Publication.spec.ts
  • ee/apps/ddp-streamer/src/Publication.ts
Use descriptive test names that clearly communicate expected behavior in Playwright tests Use `.spec.ts` extension for test files (e.g., `login.spec.ts`)

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

Files:

  • ee/apps/ddp-streamer/src/Publication.spec.ts
🔇 Additional comments (2)
ee/apps/ddp-streamer/src/Publication.ts (1)

22-27: LGTM!

ee/apps/ddp-streamer/src/Publication.spec.ts (1)

35-72: LGTM!


Walkthrough

Publication now removes its client close listener when stopped. Tests cover explicit cleanup, repeated subscription churn, and automatic stopping when the client closes.

Changes

Publication lifecycle cleanup

Layer / File(s) Summary
Listener cleanup and lifecycle coverage
ee/apps/ddp-streamer/src/Publication.ts, ee/apps/ddp-streamer/src/Publication.spec.ts
Publication.stop removes the named client close listener before deleting the subscription. Tests verify cleanup during manual stop and churn, and verify that client closure invokes the stop callback.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 6537d

This change removes stale client close listeners when publications stop while preserving existing client-close behavior. No actionable merge-blocking risk remains beyond normal checks and review.

Suggested labels: type: bug

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: cleaning up DDP publication client close listeners.
Linked Issues check ✅ Passed The implementation removes each publication's client close listener during stop cleanup. The tests cover explicit stop, repeated subscription churn, and client closure. These changes satisfy issue #42
Out of Scope Changes check ✅ Passed The changes are limited to the listener cleanup fix and its regression tests. No unrelated code changes are identified.
Full details: Linked Issues check

Explanation

The implementation removes each publication's client close listener during stop cleanup. The tests cover explicit stop, repeated subscription churn, and client closure. These changes satisfy issue #42031.

  • Fix all pre-merge checks with AI

Warning

Errors were encountered while retrieving linked issues.

Errors (1)
  • JIRA integration encountered authorization issues. Please disconnect and reconnect the integration in the CodeRabbit UI.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 2 files

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] DDP streamer retains close listeners after subscriptions stop

2 participants