DDP, Driver and Socket name three different things, and the fields don't match them

Open
#338 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Refactor
Clarity
Needs clarification
Activity status
Quiet
Tech stack
typescript

Research direction

Start with CONTEXT.md, then inspect Driver, RocketChatClient, and ISocket to compare the documented layers with the current ddp and socket fields. Trace the external sdk.current.ddp usage in Rocket.Chat.ReactNative and determine the compatibility or migration requirements. Done means the naming and layering decisions are settled with their impact on consumers documented.

Written by the indexing model from the issue text.

Description

enhancement ready-for-human

What

CONTEXT.md draws a clear line between two of these:

  • Driver — the realtime transport behind a Client, speaking one wire protocol to the server. Explicitly not a Socket.
  • Socket — the raw websocket inside a Driver.

DDP is the third word in play. In CONTEXT.md it is only ever a qualifier on the wire vocabulary — DDP message, DDP response, DDP error, DDP subscription — never a name for an object. But in the code it is used as a field name for objects, and for two different ones.

Where the names don't line up

  • Driver.ddp holds a Socket. So the field named after the protocol holds the raw websocket.
  • RocketChatClient.ddp holds a Driver. Same field name, one level up, different type.
  • RocketChatClient implements ISocket, so the Client also claims to be a Socket, which by CONTEXT.md it is not.
  • Until recently RocketChatClient also carried a socket field that held a Driver — a third name for the same thing, under the one word CONTEXT.md reserves for the websocket. That field is being removed (see #336), which is what surfaced the wider problem.

The result is that client.ddp.ddp is the Socket, and no field name predicts its own type. Reading a call site does not tell you which layer you are on.

Why it matters

The layers behave very differently — a Driver reconnects, tracks DDP subscriptions and speaks method calls; a Socket opens, closes and carries frames. Code that reaches the wrong one compiles fine and misbehaves at runtime. Rocket.Chat.ReactNative already reaches across the boundary (sdk.current.ddp for driver-level health checks), so the naming is load-bearing outside this repo too.

What to decide

  • Whether DDP should name an object at all, or stay a qualifier on wire vocabulary as CONTEXT.md has it.
  • What Driver's field for its Socket should be called.
  • What a Client's field for its Driver should be called, given ddp is the name consumers already use.
  • Whether RocketChatClient should keep implements ISocket.
  • Whether any rename can land without breaking Rocket.Chat.ReactNative, and what the migration looks like if not.

This is a naming and layering review, not a bug — worth settling before more code is written against the current names.

Dominant language
TypeScript
Stars
146
Forks
101
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from RocketChat/Rocket.Chat.js.SDK

All issues in RocketChat/Rocket.Chat.js.SDK

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.