`DDPDriver.connect` emits N `connected` events per open and resolves off its own emitter
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- typescript
- Domain
- api, networking
Research direction
First inspect Rocket.Chat.ReactNative for uses of the connected event and deprecated driver.subscriptions, since the SDK ships as source and the issue identifies those consumers as required checks. Then read lib/drivers/ddp.ts, especially the constructor, connect, connected, subscriptions, and waitForNotifyUserMediaSubs, along with ADR-0004. Done means one open echo, connect returning ddp.open(), and removal of the alias without breaking identified consumers.
Written by the indexing model from the issue text.
Description
Where: lib/drivers/ddp.ts, DDPDriver.connect and DDPDriver.connected.
Problem
There are three answers to "connected": Socket.connected, the Driver's connected event, and DDPDriver.connected.
connect registers a fresh open listener on the Socket every time it is called, with no dedupe — so N calls means N connected events per open. It then resolves by round-tripping through its own emitter rather than off open()'s promise, which makes "connect resolved" and "the Socket opened" two unrelated facts.
It also aliases this.subscriptions = this.ddp.subscriptions, feeding a field already marked @deprecated. That alias is the only reason ADR-0004 has to require forgetAllSubscriptions to mutate the map in place instead of replacing it.
Fix
- Register the
openecho once, in the constructor. - Have
connectreturnddp.open(). - Delete
DDPDriver.subscriptionsand its alias, which removes the ADR-0004 constraint rather than working around it.
Needs checking first
Both the connected event and the deprecated driver.subscriptions field are reachable from Rocket.Chat.ReactNative. The SDK ships as source, so nothing in this repo compiles the consumer — someone has to read the app before removing either.
Follow-up in the same area
waitForNotifyUserMediaSubs is the biggest method in the Driver and reaches around its own interface: it reads this.ddp.subscriptions directly and calls this.ddp.subscribe rather than its own subscribe, because the sibling reshapes the args and drops the id. Then it poll-loops on a map it does not own — a second reader on the DDP subscription bookkeeping, which is what ADR-0004 exists to prevent.
Two ways out: give DDPDriver.subscribe an optional id so no bypass is needed, or move "resubscribe these named streams and await ready" onto the Socket where the map lives. Filed as a note here rather than its own issue because dropping the subscriptions alias above dissolves most of the ownership problem — worth re-reading after that lands.
- 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from RocketChat/Rocket.Chat.js.SDK
-
refactor: delete the unused replaceLog and silence exports from lib/log.tsPossibly taken @ayushi-wq claimed this 81 days ago. Openbug ready-for-agent
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
RocketChat/Rocket.Chat.js.SDK#380 · 1 comment ·
-
refactor: delete the unassigned messages and joinedIds fields on DriverPossibly taken @arbazkhan971 claimed this 68 days ago. Openbug ready-for-agent
Difficulty 1/5 Under an hour Newbie friendliness 90/100
RocketChat/Rocket.Chat.js.SDK#379 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
RocketChat/Rocket.Chat.js.SDK#308 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
RocketChat/Rocket.Chat.js.SDK#306 ·
-
bug
Difficulty 2/5 Half a day Newbie friendliness 78/100
RocketChat/Rocket.Chat.js.SDK#254 ·
All issues in RocketChat/Rocket.Chat.js.SDK
Similar issues
-
Out of order / duplicate key error shows the key bytes as decimal or UTF-8, not hexPossibly taken @bardrop claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 86/100
-
`/leaderboard`, the page and the share image say "be the first" for a program that hasn't startedOpenbug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
codercops/discord-bot#152 ·
Maintainers usually reply within 1 day
-
bug i18n
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
endora-commerce/endora-commerce#1315 ·
Maintainers usually reply within 1 day
-
area:data-quality importer size:S
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
enorm-labs/event-junkie#5136 ·
Maintainers usually reply within 1 day
-
fix(scripts): set-device-owner.ps1 fails to parse on Windows PowerShell 5.1 (UTF-8 without BOM)Open
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Maintainers usually reply within 1 day