Skip to content

fix(ddp-client): never queue non-method frames behind a wait block#40307

Open
ggazzo wants to merge 2 commits intodevelopfrom
fix/ddp-dispatcher-non-method-frames
Open

fix(ddp-client): never queue non-method frames behind a wait block#40307
ggazzo wants to merge 2 commits intodevelopfrom
fix/ddp-dispatcher-non-method-frames

Conversation

@ggazzo
Copy link
Copy Markdown
Member

@ggazzo ggazzo commented Apr 24, 2026

Summary

  • DDPDispatcher was routing every outgoing payload (connect, sub, unsub, ping, pong, method) through the same wait-block serialization path. When the head of the queue was a wait method (e.g. login({resume})), a subsequent connect frame got queued in a new non-wait block but never sent.
  • Visible failure: a caller that dispatches a wait method before the WebSocket handshake completes wedges the connection — the socket stays open, the server never replies connected, and anyone waiting on sdk.connection hangs.
  • Fix: short-circuit DDPDispatcher.dispatch for any payload whose msg is not 'method' — emit it straight through. Method serialization between methods is unchanged.

Repro that motivated this

In a downstream branch I routed token-resume (Meteor.loginWithToken) through @rocket.chat/ddp-client before the SDK had finished its initial handshake. account.loginWithToken dispatches with wait: true; that occupied the queue head, so when ws.onopen fired client.connect() the connect frame was swallowed in a non-wait block that pushItem deliberately does not send. Status stuck at connecting indefinitely.

Scope

  • packages/ddp-client/src/DDPDispatcher.ts: widen the dispatch signature to OutgoingPayload, branch on msg.msg === 'method'.
  • Regression test in packages/ddp-client/__tests__/DDPDispatcher.spec.ts asserts connect and sub payloads are emitted immediately while a wait login block sits in the queue.
  • Existing 4 queue-serialization tests all still pass.

Test plan

  • yarn workspace @rocket.chat/ddp-client jest — 50 tests, 0 failures.
  • Smoke-check on a consumer that actually uses wait methods pre-handshake.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Fixed an issue where non-method DDP frames (connect/subscribe/unsubscribe/ping/pong) could be blocked by a waiting method, causing connection handshakes to hang; these frames are now processed immediately.
  • Tests

    • Added a test ensuring non-method frames are emitted immediately while wait-serialized methods remain serialized.
  • Chores

    • Added a changeset documenting the fix.

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented Apr 24, 2026

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
Copy link
Copy Markdown

changeset-bot Bot commented Apr 24, 2026

🦋 Changeset detected

Latest commit: e2b2d26

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 41 packages
Name Type
@rocket.chat/ddp-client Patch
@rocket.chat/livechat Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/meteor Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-voip Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/http-router Patch
@rocket.chat/model-typings Patch
@rocket.chat/models Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/abac Patch
@rocket.chat/license Patch
@rocket.chat/media-calls Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch
@rocket.chat/server-fetch Patch

Not sure what this means? Click here to learn what changesets are.

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 67cfd498-fe4e-464a-bac1-a493de1f65dd

📥 Commits

Reviewing files that changed from the base of the PR and between 82378f8 and e2b2d26.

📒 Files selected for processing (3)
  • .changeset/ddp-dispatcher-non-method-frames.md
  • packages/ddp-client/__tests__/DDPDispatcher.spec.ts
  • packages/ddp-client/src/DDPDispatcher.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • .changeset/ddp-dispatcher-non-method-frames.md
  • packages/ddp-client/src/DDPDispatcher.ts
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js}

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

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • packages/ddp-client/__tests__/DDPDispatcher.spec.ts
**/*.spec.ts

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

**/*.spec.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)

Files:

  • packages/ddp-client/__tests__/DDPDispatcher.spec.ts
🧠 Learnings (9)
📓 Common learnings
Learnt from: smirk-dev
Repo: RocketChat/Rocket.Chat PR: 39625
File: apps/meteor/app/api/server/v1/push.ts:85-97
Timestamp: 2026-03-14T14:58:58.834Z
Learning: In RocketChat/Rocket.Chat, the `push.token` POST/DELETE endpoints in `apps/meteor/app/api/server/v1/push.ts` were already migrated to the chained router API pattern on `develop` prior to PR `#39625`. `cleanTokenResult` (which strips `authToken` and returns `PushTokenResult`) and `isPushTokenPOSTProps`/`isPushTokenDELETEProps` validators already exist on `develop`. PR `#39625` only migrates `push.get` and `push.info` to the chained pattern. Do not flag `cleanTokenResult` or `PushTokenResult` as newly introduced behavior-breaking changes when reviewing this PR.
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 39677
File: packages/models/src/helpers/omnichannel/agentStatus.ts:10-29
Timestamp: 2026-03-16T22:56:54.500Z
Learning: In `packages/models/src/helpers/omnichannel/agentStatus.ts` (PR `#39677`), the `queryStatusAgentOnline` function intentionally omits the `$or` offline-status guard for non-bot agents when `isLivechatEnabledWhenAgentIdle === true`. This is by design: the setting `Livechat_enabled_when_agent_idle` (`accept_chats_when_agent_idle`) means agents should receive chats even when idle/offline, so the offline filter must be removed in that path. Bots are always status-agnostic and are always included regardless of their online/offline status. Do not flag this as a bug.
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Ensure tests run reliably in parallel without shared state conflicts

Applied to files:

  • packages/ddp-client/__tests__/DDPDispatcher.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Implement proper wait strategies for dynamic content in Playwright tests

Applied to files:

  • packages/ddp-client/__tests__/DDPDispatcher.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Maintain test isolation between test cases in Playwright tests

Applied to files:

  • packages/ddp-client/__tests__/DDPDispatcher.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Use `test.step()` for complex test scenarios to improve organization in Playwright tests

Applied to files:

  • packages/ddp-client/__tests__/DDPDispatcher.spec.ts
📚 Learning: 2026-02-24T19:22:48.358Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/omnichannel/omnichannel-send-pdf-transcript.spec.ts:66-67
Timestamp: 2026-02-24T19:22:48.358Z
Learning: In Playwright end-to-end tests (e.g., under apps/meteor/tests/e2e/...), prefer locating elements by translated text (getByText) and ARIA roles (getByRole) over data-qa attributes. If translation values change, update the corresponding test locators accordingly. Never use data-qa locators. This guideline applies to all Playwright e2e test specs in the repository and helps keep tests robust to UI text changes and accessible semantics.

Applied to files:

  • packages/ddp-client/__tests__/DDPDispatcher.spec.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • packages/ddp-client/__tests__/DDPDispatcher.spec.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • packages/ddp-client/__tests__/DDPDispatcher.spec.ts
📚 Learning: 2026-03-06T18:10:15.268Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/code/CodeBlock.spec.tsx:47-68
Timestamp: 2026-03-06T18:10:15.268Z
Learning: In tests (especially those using testing-library/dom/jsdom) for Rocket.Chat components, the HTML <code> element has an implicit ARIA role of 'code'. Therefore, screen.getByRole('code') or screen.findByRole('code') will locate <code> elements even without a role attribute. Do not flag findByRole('code') as invalid in reviews; prefer using the implicit role instead of adding role="code" unless necessary for accessibility.

Applied to files:

  • packages/ddp-client/__tests__/DDPDispatcher.spec.ts
🔇 Additional comments (1)
packages/ddp-client/__tests__/DDPDispatcher.spec.ts (1)

75-101: Solid regression coverage for non-method bypass behavior.

This test validates send order/count for login (wait: true) plus immediate emission of connect and sub, while confirming the wait block remains queued. It directly guards the handshake wedge regression.


Walkthrough

Fixes a bug in DDPDispatcher where non-method DDP frames (connect, sub, unsub, ping, pong) could be queued behind a wait: true method and not sent; non-method frames now bypass the wait-queue and are emitted immediately, while wait-serialization for method frames is unchanged.

Changes

Cohort / File(s) Summary
Documentation
.changeset/ddp-dispatcher-non-method-frames.md
Changelog entry documenting the patch fix for non-method DDP frames being blocked by a wait-queued method.
Tests
packages/ddp-client/__tests__/DDPDispatcher.spec.ts
Adds a test that dispatches a wait-queued method then non-method frames (connect, sub) and asserts each non-method is emitted immediately via send, while the original wait-block remains pending.
Implementation
packages/ddp-client/src/DDPDispatcher.ts
dispatch signature updated to accept OutgoingPayload; adds branch so non-method payloads bypass the wait/queue and call send immediately, preserving existing wait/queue behavior for method payloads.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the primary fix: preventing non-method frames from being queued behind wait blocks in DDPDispatcher.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@ggazzo ggazzo force-pushed the fix/ddp-dispatcher-non-method-frames branch from 54a2e5e to 82378f8 Compare April 24, 2026 23:31
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/ddp-client/src/DDPDispatcher.ts (1)

19-38: Correct fix; consider trimming the inline rationale per project style.

The branch on payload.msg !== 'method' correctly partitions the OutgoingPayload union — only MethodPayload carries msg: 'method', so all protocol frames (connect, sub/unsub, ping/pong) bypass the wait queue while the existing serialization for methods is preserved unchanged. Behavior aligns with the consumer dispatch sites in MinimalDDPClient.ts (subscribe/connect/ping/pong).

That said, the multi-line implementation comment at lines 20–26 conflicts with the project's "avoid code comments in the implementation" rule. The rationale would be better captured in the changeset/PR description (which already covers it) or in a unit test name, leaving the source terse.

♻️ Proposed style tweak
 	override dispatch(payload: OutgoingPayload, options?: { wait?: boolean }) {
-		// Only method payloads participate in the wait/queue serialization that
-		// implements Meteor's wait-method semantics. Protocol-level frames
-		// (connect, sub, unsub, ping, pong) must be delivered immediately:
-		// queueing a `connect` frame behind a wait `login` block, for example,
-		// wedges the DDP handshake — the socket opens but `connect` never
-		// reaches the server, so the server never replies `connected` and the
-		// session never establishes.
 		if (payload.msg !== 'method') {
 			this.emit('send', payload);
 			return;
 		}

As per coding guidelines: "Avoid code comments in the implementation".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/ddp-client/src/DDPDispatcher.ts` around lines 19 - 38, The
multi-line implementation comment above the dispatch method is too verbose per
the "avoid code comments in the implementation" guideline; keep the behavior but
remove or replace the long rationale with a concise one-line comment (or move
the detailed explanation to the PR description or a unit test name).
Specifically, in dispatch (method signature dispatch(payload: OutgoingPayload,
...)) leave the short intent comment (or none), retain the existing logic that
checks payload.msg !== 'method' and calls this.emit('send', payload), the
options?.wait branch that calls this.wait(payload), and the
this.pushItem(payload) branch unchanged; just trim the explanatory block to a
single brief line or remove it entirely.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/ddp-client/src/DDPDispatcher.ts`:
- Around line 19-38: The multi-line implementation comment above the dispatch
method is too verbose per the "avoid code comments in the implementation"
guideline; keep the behavior but remove or replace the long rationale with a
concise one-line comment (or move the detailed explanation to the PR description
or a unit test name). Specifically, in dispatch (method signature
dispatch(payload: OutgoingPayload, ...)) leave the short intent comment (or
none), retain the existing logic that checks payload.msg !== 'method' and calls
this.emit('send', payload), the options?.wait branch that calls
this.wait(payload), and the this.pushItem(payload) branch unchanged; just trim
the explanatory block to a single brief line or remove it entirely.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 40d19712-78e1-4707-b629-f549b056354c

📥 Commits

Reviewing files that changed from the base of the PR and between ceefff9 and 82378f8.

📒 Files selected for processing (3)
  • .changeset/ddp-dispatcher-non-method-frames.md
  • packages/ddp-client/__tests__/DDPDispatcher.spec.ts
  • packages/ddp-client/src/DDPDispatcher.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: CodeQL-Build
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js}

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

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • packages/ddp-client/__tests__/DDPDispatcher.spec.ts
  • packages/ddp-client/src/DDPDispatcher.ts
**/*.spec.ts

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

**/*.spec.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)

Files:

  • packages/ddp-client/__tests__/DDPDispatcher.spec.ts
🧠 Learnings (10)
📓 Common learnings
Learnt from: smirk-dev
Repo: RocketChat/Rocket.Chat PR: 39625
File: apps/meteor/app/api/server/v1/push.ts:85-97
Timestamp: 2026-03-14T14:58:58.834Z
Learning: In RocketChat/Rocket.Chat, the `push.token` POST/DELETE endpoints in `apps/meteor/app/api/server/v1/push.ts` were already migrated to the chained router API pattern on `develop` prior to PR `#39625`. `cleanTokenResult` (which strips `authToken` and returns `PushTokenResult`) and `isPushTokenPOSTProps`/`isPushTokenDELETEProps` validators already exist on `develop`. PR `#39625` only migrates `push.get` and `push.info` to the chained pattern. Do not flag `cleanTokenResult` or `PushTokenResult` as newly introduced behavior-breaking changes when reviewing this PR.
Learnt from: d-gubert
Repo: RocketChat/Rocket.Chat PR: 39857
File: apps/meteor/app/lib/server/lib/debug.js:87-91
Timestamp: 2026-04-23T18:14:24.851Z
Learning: In `apps/meteor/app/lib/server/lib/debug.js`, the `wrapMethods` function wraps Meteor DDP method handlers inside a `tracerActiveSpan` callback. The `end()` (summary timer) and `endHistogram()` (histogram timer) calls are placed after `await originalHandler.apply(this, originalArgs)` without a try/finally guard. This is intentional and safe: errors thrown by Meteor method handlers are caught by the route-handler action wrapper in `apps/meteor/app/api/server/ApiClass.ts` (around line 892-893), which converts them into proper response objects, so execution flow is never disrupted and the timer calls are always reached. Do not flag the missing try/finally as a bug for these timer calls in `debug.js`.
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Implement proper wait strategies for dynamic content in Playwright tests

Applied to files:

  • packages/ddp-client/__tests__/DDPDispatcher.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Ensure tests run reliably in parallel without shared state conflicts

Applied to files:

  • packages/ddp-client/__tests__/DDPDispatcher.spec.ts
📚 Learning: 2025-11-24T17:08:17.065Z
Learnt from: CR
Repo: RocketChat/Rocket.Chat PR: 0
File: .cursor/rules/playwright.mdc:0-0
Timestamp: 2025-11-24T17:08:17.065Z
Learning: Applies to apps/meteor/tests/e2e/**/*.spec.ts : Use `page.waitFor()` with specific conditions instead of hardcoded timeouts in Playwright tests

Applied to files:

  • packages/ddp-client/__tests__/DDPDispatcher.spec.ts
📚 Learning: 2026-02-24T19:22:48.358Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/omnichannel/omnichannel-send-pdf-transcript.spec.ts:66-67
Timestamp: 2026-02-24T19:22:48.358Z
Learning: In Playwright end-to-end tests (e.g., under apps/meteor/tests/e2e/...), prefer locating elements by translated text (getByText) and ARIA roles (getByRole) over data-qa attributes. If translation values change, update the corresponding test locators accordingly. Never use data-qa locators. This guideline applies to all Playwright e2e test specs in the repository and helps keep tests robust to UI text changes and accessible semantics.

Applied to files:

  • packages/ddp-client/__tests__/DDPDispatcher.spec.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • packages/ddp-client/__tests__/DDPDispatcher.spec.ts
  • packages/ddp-client/src/DDPDispatcher.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • packages/ddp-client/__tests__/DDPDispatcher.spec.ts
  • packages/ddp-client/src/DDPDispatcher.ts
📚 Learning: 2026-03-06T18:10:15.268Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/code/CodeBlock.spec.tsx:47-68
Timestamp: 2026-03-06T18:10:15.268Z
Learning: In tests (especially those using testing-library/dom/jsdom) for Rocket.Chat components, the HTML <code> element has an implicit ARIA role of 'code'. Therefore, screen.getByRole('code') or screen.findByRole('code') will locate <code> elements even without a role attribute. Do not flag findByRole('code') as invalid in reviews; prefer using the implicit role instead of adding role="code" unless necessary for accessibility.

Applied to files:

  • packages/ddp-client/__tests__/DDPDispatcher.spec.ts
📚 Learning: 2026-02-25T20:10:16.987Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38913
File: packages/ddp-client/src/legacy/types/SDKLegacy.ts:34-34
Timestamp: 2026-02-25T20:10:16.987Z
Learning: In the RocketChat/Rocket.Chat monorepo, packages/ddp-client and apps/meteor do not use TypeScript project references. Module augmentations in apps/meteor (e.g., declare module 'rocket.chat/rest-typings') are not visible when compiling packages/ddp-client in isolation, which is why legacy SDK methods that depend on OperationResult types for OpenAPI-migrated endpoints must remain commented out.

Applied to files:

  • .changeset/ddp-dispatcher-non-method-frames.md
📚 Learning: 2026-03-16T21:50:37.589Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:37.589Z
Learning: For changes related to OpenAPI migrations in Rocket.Chat/OpenAPI, when removing endpoint types and validators from rocket.chat/rest-typings (e.g., UserRegisterParamsPOST, /v1/users.register) document this as a minor changeset (not breaking) per RocketChat/Rocket.Chat-Open-API#150 Rule 7. Note that the endpoint type is re-exposed via a module augmentation .d.ts in the consuming package (e.g., packages/web-ui-registration/src/users-register.d.ts). In reviews, ensure the changeset clearly states: this is a non-breaking change, the major version should not be bumped, and the changeset reflects a minor version bump. Do not treat this as a breaking change during OpenAPI migrations.

Applied to files:

  • .changeset/ddp-dispatcher-non-method-frames.md
🔇 Additional comments (2)
packages/ddp-client/__tests__/DDPDispatcher.spec.ts (1)

75-101: Solid regression coverage.

The test exercises the exact wedge scenario: a { wait: true } method at the queue head followed by connect/sub frames. Assertions verify both emission order/count via the send listener and the residual queue shape ([{ wait: true, items: [login] }]), confirming the non-method frames bypass the queue without consuming the pending wait block.

.changeset/ddp-dispatcher-non-method-frames.md (1)

1-5: Changeset is appropriately scoped.

Patch bump matches the nature of the fix (no public API surface change), and the description concisely captures the symptom (handshake wedge) and the remediation.

ggazzo added 2 commits April 24, 2026 20:40
DDPDispatcher's pushItem path runs for every payload that goes through
dispatch — including connect, sub, unsub, and ping/pong. When the head
of the queue is a wait block (e.g. a login), pushItem deliberately
returns without sending so the next method waits. Applied to a non-
method payload, that means the connect frame ws.onopen emits gets
dropped on the floor: the socket sits open, the DDP handshake never
happens, and any caller waiting on `connected` hangs forever.

Visible failure mode: token-resume on page reload dispatched the wait
login while the socket was still connecting; when ws.onopen later
fired the connect frame, it was queued behind that login and never
sent. Status stuck at "connecting".

Fix: short-circuit dispatch for any payload whose msg is not 'method'
— emit it straight away. Wait/queue serialization is a property of
method calls, not protocol frames.
@ggazzo ggazzo force-pushed the fix/ddp-dispatcher-non-method-frames branch from 82378f8 to e2b2d26 Compare April 24, 2026 23:41
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.85%. Comparing base (72fb0bd) to head (e2b2d26).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40307      +/-   ##
===========================================
+ Coverage    69.81%   69.85%   +0.03%     
===========================================
  Files         3296     3296              
  Lines       119173   119176       +3     
  Branches     21468    21476       +8     
===========================================
+ Hits         83198    83246      +48     
+ Misses       32675    32634      -41     
+ Partials      3300     3296       -4     
Flag Coverage Δ
e2e 59.83% <ø> (+0.08%) ⬆️
e2e-api 46.23% <ø> (-0.04%) ⬇️
unit 70.58% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant