RocketChat / RocketChat/Rocket.Chat

UI Crash (RangeError) in Channel Directory when lastMessage has reactions but missing timestamp

Open Beginner friendly
#40,503 0 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:

The Channel Directory crashes the entire UI with an Uncaught RangeError: Invalid time value when navigating to /directory/channels. This happens if a channel's lastMessage metadata contains a reactions object but lacks a ts (timestamp) field. This state can be reached by disabling the "Save Last Message" setting, enable again and interact with messages sent while the setting was disabled.

Steps to reproduce:
  1. Go to Workspace Settings and disable the "Save Last Message" setting.
  2. Create new channel to be sure that it has no last message stored
  3. Send a message to new channel
  4. Go back to settings and enable the "Save Last Message" setting.
  5. Add a reaction (emoji) to the message you sent in Step 3.
  6. Navigate to /directory/channels
Expected behavior:

The directory should load normally. If a timestamp is missing for the last message, the "Last Message" column should either be empty or show a placeholder without crashing the application.

Actual behavior:

The application GUI crashes with an "Application Error" screen.

Server Setup Information:
  • Version of Rocket.Chat Server: latest develop branch and 8.4.0
  • License Type: enterprise
  • Number of Users: > 100
  • Operating System: debian trixie
  • Deployment Method: docker
  • Number of Running Instances: 1
  • DB Replicaset Oplog: na
  • NodeJS Version: 22.22.2
  • MongoDB Version: 8.2.7
Client Setup Information
  • Desktop App or Browser Version: chrome 148.0.7778.96
  • Operating System: debian bookworm
Additional context

State of the directory API when the error occurs:

http://localhost:3000/api/v1/directory?count=25&type=channels&workspace=local&sort=%7B%22name%22%3A1%7D

{
	"result": [
		{
			"_id": "GENERAL",
			"ts": "2026-05-12T13:02:27.252Z",
			"t": "c",
			"name": "general",
			"usersCount": 1,
			"default": true,
		},
		{
			"_id": "6a042d0e86e0c2a37b0c19b0",
			"fname": "qq",
			"topic": "",
			"name": "qq",
			"t": "p",
			"usersCount": 1,
			"ts": "2026-05-13T07:49:34.050Z",
			"default": false,
			"lastMessage": {
				"reactions": {
					":stuck_out_tongue:": {
						"usernames": [
							"adam.admin"
						]
					}
				}
			}
		}
	],
	"count": 2,
	"offset": 0,
	"total": 2,
	"success": true
}
Relevant logs:

Server Log is ok
Browser Log:

Uncaught RangeError: Invalid time value
    at format (format.js:358:11)
    at safeFormat (dateFormat.ts:193:10)
    at formatDate (dateFormat.ts:199:9)
    at eval (useFormatDate.ts:8:55)
    at ChannelsTableRow (ChannelsTableRow.tsx:50:22)
    at renderWithHooks (modules.js?hash=b1aaff80e14880c75f56b39e02105db0dbd4fd69:68796:18)
    at mountIndeterminateComponent (modules.js?hash=b1aaff80e14880c75f56b39e02105db0dbd4fd69:73413:13)
    at beginWork (modules.js?hash=b1aaff80e14880c75f56b39e02105db0dbd4fd69:74936:16)
    at HTMLUnknownElement.callCallback (modules.js?hash=b1aaff80e14880c75f56b39e02105db0dbd4fd69:57474:14)
    at Object.invokeGuardedCallbackDev (modules.js?hash=b1aaff80e14880c75f56b39e02105db0dbd4fd69:57523:16)Understand this error


modules.js?hash=b1aaff80e14880c75f56b39e02105db0dbd4fd69:72014 The above error occurred in the <ChannelsTableRow> component:

    at ChannelsTableRow (/client/views/directory/tabs/channels/ChannelsTable/ChannelsTableRow.tsx:17:29)
    at tbody
    at Box (http://localhost:3000/packages/modules.js?hash=b1aaff80e14880c75f56b39e02105db0dbd4fd69:9305:54)
    at TableBody
    at GenericTableBody
    at table
    at Box (http://localhost:3000/packages/modules.js?hash=b1aaff80e14880c75f56b39e02105db0dbd4fd69:9305:54)
    at div
    at Box (http://localhost:3000/packages/modules.js?hash=b1aaff80e14880c75f56b39e02105db0dbd4fd69:9305:54)
    at Table (http://localhost:3000/packages/modules.js?hash=b1aaff80e14880c75f56b39e02105db0dbd4fd69:18987:18)
    at div
    at Box (http://localhost:3000/packages/modules.js?hash=b1aaff80e14880c75f56b39e02105db0dbd4fd69:9305:54)
    at BaseScrollbars
    at CustomScrollbars (http://localhost:3000/packages/modules.js?hash=b1aaff80e14880c75f56b39e02105db0dbd4fd69:5133:11)
    at div
    at Box (http://localhost:3000/packages/modules.js?hash=b1aaff80e14880c75f56b39e02105db0dbd4fd69:9305:54)
    at GenericTable (http://localhost:3000/packages/modules.js?hash=b1aaff80e14880c75f56b39e02105db0dbd4fd69:6657:11)
    at ChannelsTable (/client/views/directory/tabs/channels/ChannelsTable/ChannelsTable.tsx:21:15)
    at ChannelsTab (/client/views/directory/tabs/channels/ChannelsTab.tsx:14:32)
    at div
    at Box (http://localhost:3000/packages/modules.js?hash=b1aaff80e14880c75f56b39e02105db0dbd4fd69:9305:54)
    at PageContent
    at section
    at Box (http://localhost:3000/packages/modules.js?hash=b1aaff80e14880c75f56b39e02105db0dbd4fd69:9305:54)
    at Page (http://localhost:3000/packages/modules.js?hash=b1aaff80e14880c75f56b39e02105db0dbd4fd69:4773:11)
    at DirectoryPage (/client/views/directory/DirectoryPage.tsx:19:19)
    at Suspense
    at main
    at Box (http://localhost:3000/packages/modules.js?hash=b1aaff80e14880c75f56b39e02105db0dbd4fd69:9305:54)
    at MainContent (/client/views/root/MainLayout/MainContent.tsx:12:24)
    at div
    at Box (http://localhost:3000/packages/modules.js?hash=b1aaff80e14880c75f56b39e02105db0dbd4fd69:9305:54)
    at LayoutWithSidebar (/client/views/root/MainLayout/LayoutWithSidebar.tsx:25:30)
    at TwoFactorAuthSetupCheck (/client/views/root/MainLayout/TwoFactorAuthSetupCheck.tsx:17:36)
    at PasswordChangeCheck (/client/views/root/MainLayout/PasswordChangeCheck.tsx:16:32)
    at UsernameCheck (/client/views/root/MainLayout/UsernameCheck.tsx:16:26)
    at LoggedInArea (/client/views/root/MainLayout/LoggedInArea.tsx:24:25)
    at AuthenticationCheck (/client/views/root/MainLayout/AuthenticationCheck.tsx:23:36)
    at Preload (/client/views/root/MainLayout/Preload.tsx:14:20)
    at MainLayout (/client/views/root/MainLayout/MainLayout.tsx:16:23)
    at AppLayoutThemeWrapper (/client/components/AppLayoutThemeWrapper.tsx:12:34)
    at DocumentTitleWrapper (/client/views/root/DocumentTitleWrapper.tsx:31:33)
    at Suspense
    at AppLayout (/client/views/root/AppLayout.tsx:46:5)
    at OmnichannelProvider (/client/providers/OmnichannelProvider.tsx:41:32)
    at MediaCallProvider (/client/providers/MediaCallProvider.tsx:15:30)
    at VideoConfContextProvider (/client/providers/VideoConfProvider.tsx:17:37)
    at ActionManagerProvider (/client/providers/ActionManagerProvider.tsx:17:34)
    at UserPresenceProvider (/client/providers/UserPresenceProvider.tsx:15:33)
    at OmnichannelRoomIconProvider (/client/components/RoomIcon/OmnichannelRoomIcon/provider/OmnichannelRoomIconProvider.tsx:16:40)
    at EmojiPickerProvider (/client/providers/EmojiPickerProvider/EmojiPickerProvider.tsx:19:32)
    at AuthorizationProvider (/client/providers/AuthorizationProvider.tsx:16:34)
    at ModalProvider (http://localhost:3000/packages/modules.js?hash=b1aaff80e14880c75f56b39e02105db0dbd4fd69:7543:26)
    at DeviceProvider (/client/providers/DeviceProvider/DeviceProvider.tsx:32:27)
    at CustomSoundProvider (/client/providers/CustomSoundProvider/CustomSoundProvider.tsx:17:32)
    at AuthenticationProvider (/client/providers/AuthenticationProvider/AuthenticationProvider.tsx:28:35)
    at LayoutProvider (/client/providers/LayoutProvider.tsx:20:27)
    at UserProvider (/client/providers/UserProvider/UserProvider.tsx:55:25)
    at AvatarUrlProvider (/client/providers/AvatarUrlProvider.tsx:14:30)
    at ToastMessageInnerProvider (/client/providers/ToastMessagesProvider.tsx:19:38)
    at ToastBarProvider (/node_modules/@rocket.chat/fuselage-toastbar/dist/esm/ToastBarProvider.js:21:29)
    at ToastMessagesProvider (/client/providers/ToastMessagesProvider.tsx:92:34)
    at TooltipProvider (http://localhost:3000/packages/modules.js?hash=b1aaff80e14880c75f56b39e02105db0dbd4fd69:7614:28)
    at SessionProvider (/client/providers/SessionProvider.tsx:27:28)
    at TranslationProviderInner (/client/providers/TranslationProvider.tsx:216:37)
    at I18nextProvider (http://localhost:3000/packages/modules.js?hash=b1aaff80e14880c75f56b39e02105db0dbd4fd69:116837:5)
    at TranslationProvider (/client/providers/TranslationProvider.tsx:166:32)
    at SettingsProvider (/client/providers/SettingsProvider.tsx:22:29)
    at RouterProvider (/client/providers/RouterProvider.tsx:14:27)
    at ServerProvider (/client/providers/ServerProvider.tsx:135:27)
    at MeteorProvider (/client/providers/MeteorProvider.tsx:31:27)
    at QueryClientProvider (http://localhost:3000/packages/modules.js?hash=b1aaff80e14880c75f56b39e02105db0dbd4fd69:118140:3)
    at Suspense
    at ErrorBoundary (/node_modules/react-error-boundary/dist/react-error-boundary.umd.js:78:37)
    at OutermostErrorBoundary (/client/views/root/OutermostErrorBoundary.tsx:27:35)
    at AppRoot

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 at client/views/directory/tabs/channels/ChannelsTable/ChannelsTableRow.tsx, following the stack trace through useFormatDate.ts and dateFormat.ts. Reproduce the directory view with a lastMessage containing reactions but no ts, then verify the ChannelsTable renders without a RangeError and shows an empty or placeholder Last Message value.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.