Rocket.Chat.ReactNative: Request to `/api/v1/chat.syncMessages` fails with `The \"lastUpdate\" query parameter must be a valid date.`
Description:
The app sends requests to /api/v1/chat.syncMessages?roomId=ROOMID&lastUpdate=undefined. The back end returns an error:
"level":35,"time":"2024-12-13T19:57:58.602Z","pid":1040862,"hostname":"rocketchat","name":"API","method":"GET","url":"/api/v1/chat.syncMessages?roomId=ROOMID&lastUpdate=undefined","userId":"USERID","userAgent":"RC Mobile; android 9; v4.55.0 (70132)","host":"rc.example.com","remoteIP":"USERIP","err":{"type":"errorClass","message":"The \"lastUpdate\" query parameter must be a valid date. [error-roomId-param-invalid]","stack":"Error: The \"lastUpdate\" query parameter must be a valid date. [error-roomId-param-invalid]\n at app/api/server/v1/chat.ts:91:11\n at /opt/Rocket.Chat/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/fiber_pool.js:43:40\n => awaited here:\n at Function.Promise.await (/opt/Rocket.Chat/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/promise_server.js:56:12)\n at packages/meteor.js:367:22\n at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1389:31)\n at app/api/server/api.ts:649:39\n at /opt/Rocket.Chat/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/fiber_pool.js:43:40","isClientSafe":true,"error":"error-roomId-param-invalid","reason":"The \"lastUpdate\" query parameter must be a valid date.","errorType":"Meteor.Error"},"status":400,"responseTime":2,"msg":"The \"lastUpdate\" query parameter must be a valid date. [error-roomId-param-invalid]"}
Environment Information:
- Rocket.Chat Server Version: 6.13.1
- Rocket.Chat App Version: v4.55.0 and others
- Device Name:
- OS Version: Android/iOS all versions
Steps to reproduce:
I cannot provide exact steps to reproduce.
Expected behavior:
The app should always send a date in lastUpdate. Alternatively, the server should accept undefined lastUpdate.
Actual behavior:
N/A
Additional context:
We have some reports by users that they click on push notifications but the message does not load in channels. We suspect that this could be related.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 30 (13 by maintainers)
Sorry, I didn’t fully understand, we’ll wait for the latest release)
@Den4ik92 Gave it a try on https://github.com/RocketChat/Rocket.Chat.ReactNative/pull/6485 I wrote a quick load test with Maestro to understand the difference, but I was not able to reproduce in none of the scenarios.
While I agree
setTimeoutwon’t work properly in background, the content inside of it is going to be triggered after 1 second. I wonder if that’s enough time to cause any issues, but I don’t doubt it. That part of the code was written a long time ago, before Hermes or JSI, so perhaps removing the setTimeout won’t impact so much, but we need to test it properly.I’m going to give it another shot tomorrow. I think
goRoomcan also be the issue here, since it’s dispatching a navigation to RoomView even though it’s already positioned in the correct room.@diegolmello I think I understood how and why this bug occurs:
The room must be open (active subscription to the room) which we will then open via deeplink
The application must be minimized!!!
Send a message to the mobile client only after we minimize the mobile client. –What is happening: 3-1) the handleMessageReceived function is executed but the logic inside it does not work, since the setTimeout() function does not work in the background when the application is minimized)
Open the room via deeplink the execution of the handleMessageReceived logic does not occur –What is happening: 4-1) Unsubscribing from a room to which you were previously subscribed 4-2) New subscription to the room
P.S. For now, I have solved the problem for myself by removing setTimeout() from handleMessageReceived. I understand that this will load the processor when receiving messages in a subscribed chat, but receiving messages is more important to me now.
Perhaps there is a more correct solution, I would be very grateful for a hint))