Skip to content

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

Description

@diegolmello

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 refactor: hold the Driver directly as ddp, instead of an always-resolved socket Promise #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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions