RocketChat / RocketChat/Rocket.Chat
Apps-Engine Deno runtime sendRequest can hang forever because it has no response timeout
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 46.1k
- Forks
- 13.9k
- Avg merge
- 3d 3h
- Merged PRs (30d)
- 130
Description
Description:
In messenger.ts, the sendRequest function creates a responsePromise that waits indefinitely for a response:${request.id} event on RPCResponseObserver. If the Deno subprocess never returns a response, the promise remains pending and the caller is blocked. Additionally, the request id is generated using Math.random(), which is not ideal for unique IDs.
Expected behavior:
sendRequest should reject after a reasonable timeout and clean up the event listener, so pending requests cannot leak or hang the process forever.
Suggested fix:
Race the response promise against a setTimeout promise.
Remove the event listener in both the success/timeout cases.
Consider replacing the Math.random() id with crypto.randomUUID() or a sequential/counter-based id.
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 in messenger.ts at sendRequest, then trace RPCResponseObserver and the response:${request.id} listener. Confirm how requests and responses are matched before defining the timeout and cleanup behavior; done means an unanswered request rejects after a reasonable timeout, successful responses still resolve, and listeners do not remain pending.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- deno, typescript
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100