RocketChat / RocketChat/Rocket.Chat
'send-many-messages' permission not respected when sending via Rocket.Chat.js.SDK
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
Description:
Sending frequent messages (more than 5/sec) using Rocket.Chat.js.SDK raises an error despite having assigned permission 'send-many-messages' to a user.
Steps to reproduce:
- Use the bot example from https://developer.rocket.chat/v1/docs/develop-a-rocketchat-sdk-bot
- Replace the processMessages function with:
const processMessages = async (err, message, messageOptions) => {
if (!err) {
if (message.u._id === myUserId) return;
for(let i=0;i<10;i++) await driver.sendToRoomId('Hi there! - '+i, message.rid);
}
};
- Run
node server.jsand send a random message to the user.
Expected behavior:
The response shoule be 10 greetings like Hi there! - 0 with numbers from 0 to 9.
Actual behavior:
5 messages are sent and the error is returned:
[sendMessage] Error: {
isClientSafe: true,
error: 'too-many-requests',
reason: 'Error, too many requests. Please slow down. You must wait 1 seconds before trying again.',
details: { timeToReset: 425 },
message: 'Error, too many requests. Please slow down. You must wait 1 seconds before trying again. [too-many-requests]',
errorType: 'Meteor.Error'
}
Temporary workaround
An introduction of a send delay like this solves the issue:
for(let i=0;i<10;i++) setTimeout(async ()=>{await driver.sendToRoomId('Hi there! - '+i, message.rid)},i*200);
Server Setup Information:
- Version of Rocket.Chat Server: 7.1.0
- License Type: Starter
- Deployment Method: tar
- NodeJS Version: 20.17
- MongoDB Version: 6.0.19
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
Reproduce the issue with the Rocket.Chat.js.SDK bot example, replacing processMessages and running node server.js. Start by tracing driver.sendToRoomId and the server-side handling of the send-many-messages permission and request limit. Done means ten messages can be sent without the too-many-requests error when the permission is assigned, while normal limiting remains intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- authorization, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100