RocketChat / RocketChat/Rocket.Chat

Exception while invoking method 'loadSurroundingMessages'

Open
#40,119 8 comments 2 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:

Been getting an error more recently on RocketChat 8.3.1 with the above bug report title and the below error showing up in one of my channels.

I believe it's causing RocketChat to crash as I have been getting a lot of logs of Caddy getting connection refused on the reverse proxy.

Error: Match error: Expected boolean, got string
    at format (packages/check/match.js:11:15)
    at check (packages/check/match.js:53:13)
    at MethodInvocation.loadSurroundingMessages (server/methods/loadSurroundingMessages.ts:32:3)
    at app/lib/server/lib/debug.js:85:42
    at tracerActiveSpan (/app/bundle/programs/server/npm/node_modules/@rocket.chat/tracing/src/index.ts:103:61)
    at MethodInvocation.methodsMap.<computed> (app/lib/server/lib/debug.js:76:10)
    at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1748:12)
    at packages/ddp-server/livedata_server.js:601:19
    at AsyncLocalStorage.run (node:internal/async_local_storage/async_hooks:91:14)
    at EnvironmentVariableAsync.withValue (packages/meteor.js:1431:29)
    at packages/ddp-server/livedata_server.js:599:46
    at AsyncLocalStorage.run (node:internal/async_local_storage/async_hooks:91:14)
    at EnvironmentVariableAsync.withValue (packages/meteor.js:1431:29)
    at packages/ddp-server/livedata_server.js:597:46
    at new Promise (<anonymous>)
    at Session.method (packages/ddp-server/livedata_server.js:571:23)
    at runHandlers (packages/ddp-server/livedata_server.js:423:58)
    at processNext (packages/ddp-server/livedata_server.js:440:7)
    at Session.processMessage (packages/ddp-server/livedata_server.js:443:5)
    at SockJSConnection.<anonymous> (packages/ddp-server/livedata_server.js:1324:31)
    at SockJSConnection.emit (node:events:518:28)
    at SockJSConnection.emit (node:domain:489:12)
Steps to reproduce:

Not sure how exactly it keeps happening.

Expected behavior:

No errors in my channels and a smooth connection.

Actual behavior:

The above log, errors that Caddy can't commmunicate through the reverse proxy (connection refused), and I also get SSLhandshake errors from Mongo saying that SSL was requested even though the server (Mongo) was not started with SSL.

Server Setup Information:
  • Version of Rocket.Chat Server: 8.3.1
  • License Type: Starter
  • Number of Users: 14
  • Operating System: Ubuntu Server 24.04 LTS
  • Deployment Method: Docker
  • Number of Running Instances: 1
  • DB Replicaset Oplog: Oplog disabled
  • NodeJS Version: v22.16.0
  • MongoDB Version: 8.0.20
Client Setup Information
  • Desktop App or Browser Version: Desktop app v4.14 / Android app v4.71.2. I don't use it in the browser.
  • Operating System: Windows 11 and Android 16
Additional context

I haven't changed anything with the config of the server besides updating RocketChat and Mongo when new releases are available. I've been staying in Mongo 8.

Relevant logs:

Log is above.

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 with server/methods/loadSurroundingMessages.ts at line 32 and compare its argument checks with the reported Match error from packages/check/match.js. Try reproducing the failure through the desktop or Android client on Rocket.Chat 8.3.1 using the supplied Docker and MongoDB setup. Done means the method no longer logs the type error and channel connections remain stable.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.