RocketChat / RocketChat/Rocket.Chat

Apps-Engine Deno runtime sendRequest can hang forever because it has no response timeout

Open
#41,798 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.