RocketChat / RocketChat/Rocket.Chat
back-compatibility in realtime api causes 500 "Internal server error"
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
Description:
Hi, since the last update to 6.5.0 the parameter back-compatibility for the realtime api is broken and causes a 500 Internal Server Error.
We have build some bots which are using the the back-compatibility flag set to true to have the msg event as "added" instead of "changed" but this is not broken since the update 6.5.0 (also broken in 6.5.2)
Steps to reproduce:
- Install RocketChat 6.5.0
- Connect to Realtime Api with the following parameters:
ddp.Sub("stream-room-messages", "__my_messages__", true)
- Get the error
Expected behavior:
I would except that my client can connect as documented and no Internal Server Error is thrown
Actual behavior:
RocketChat is responding to the subscribton command with a internal server error
"name":"DDP-Streamer",
"msg":"Subscription error",
"err":{
"type":"TypeError",
"message":"Cannot read property 'added' of undefined",
"stack":"TypeError: Cannot read property 'added' of undefined
\n at Object.added [as sendAdded] (/app/ee/apps/ddp-streamer/src/Publication.js:39:21)
\n at Stream._publish (/app/apps/meteor/server/modules/streamer/streamer.module.js:148:34)
\n at runMicrotasks (<anonymous>)
\n at processTicksAndRejections (internal/process/task_queues.js:95:5)
\n at async Server.subscribe (/app/ee/apps/ddp-streamer/src/Server.js:94:13)"}}
Server Setup Information:
- Version of Rocket.Chat Server: 6.5.0 (also tested with 6.5.2)
- Deployment Method: docker
Client Setup Information
- Go SDK
Additional context
Docs of the API we use: https://developer.rocket.chat/reference/api/realtime-api/subscriptions/streamlivechatroom
A workaround so far i have found would be to set the back-compatibility to false but then the msg is "changed" and not "added" which need additional changes in the lower level libraries like ddp.
Relevant logs:
Server logs are above.
Client logs:
debug sub returned a nosub error msg=map[error:map[error:500 errorType:Meteor.Error isClientSafe:true message:Internal server error [500] reason:Internal server error] id:2 msg:nosub]
Contributor guide
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.
Research direction
Start with ee/apps/ddp-streamer/src/Publication.js at line 39, then trace the call from apps/meteor/server/modules/streamer/streamer.module.js line 148 and Server.js line 94. Reproduce the stream-room-messages subscription with back-compatibility set to true. Done means the documented subscription no longer returns a 500 and preserves the expected compatibility behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100