RocketChat / Rocket.Chat

The communications platform that puts data protection first.
https://rocket.chat/
Other
40.08k stars 10.34k forks source link

back-compatibility in realtime api causes 500 "Internal server error" #31410

Open eloo-abi opened 8 months ago

eloo-abi commented 8 months ago

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:

  1. Install RocketChat 6.5.0
  2. Connect to Realtime Api with the following parameters:
    ddp.Sub("stream-room-messages", "__my_messages__", true)
  3. 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:

Client Setup Information

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]
pierre-lehnen-rc commented 7 months ago

The error is probably thrown because this function reference is not bound to the publication instance:

https://github.com/RocketChat/Rocket.Chat/blob/bc1f26f932a8e07642928a72752bb19491b07348/ee/apps/ddp-streamer/src/Publication.ts#L22

Not sure why this would start happening on 6.5 though. My first guess would be that the bug itself is older but something else in your setup changed with the 6.5 update.

eloo-abi commented 7 months ago

any updates here for this breaking change bug?