RocketChat / RocketChat/Rocket.Chat.ReactNative
Cannot update a record with pending changes
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2.4k
- Forks
- 1.5k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 90
Description
Description:
Some messages within the conversation encounter the following issues.
Diagnostic error: Cannot update a record with pending changes
Environment Information:
- Rocket.Chat Server Version:
- Rocket.Chat App Version:
- Device Name:
- OS Version:
Steps to reproduce:
- Enter a conversation, with a very low probability of occurrence.
Expected behavior:
Within the conversation, messages can be updated and further actions can be performed.
Actual behavior:
There's a probability that a certain batch of messages may not update correctly.
Additional context:
After examining the logs, it is suspected that the issue is caused by the following:
In the https://github.com/RocketChat/Rocket.Chat.ReactNative/blob/bb59d980b23484a7897611de77d6847bcfad77f4/app/lib/methods/subscriptions/room.ts#L314 method that handles message updates over a certain period of time.
All creations and updates are stored in
https://github.com/RocketChat/Rocket.Chat.ReactNative/blob/bb59d980b23484a7897611de77d6847bcfad77f4/app/lib/methods/subscriptions/room.ts#L244
If there is a slightly long-running task when executing
https://github.com/RocketChat/Rocket.Chat.ReactNative/blob/bb59d980b23484a7897611de77d6847bcfad77f4/app/lib/methods/subscriptions/room.ts#L332
before reaching db.batch,
https://github.com/RocketChat/Rocket.Chat.ReactNative/blob/bb59d980b23484a7897611de77d6847bcfad77f4/app/lib/methods/subscriptions/room.ts#L341
because
https://github.com/RocketChat/Rocket.Chat.ReactNative/blob/bb59d980b23484a7897611de77d6847bcfad77f4/app/lib/methods/subscriptions/room.ts#L327
the next timer execution may be triggered.
At this point,
https://github.com/RocketChat/Rocket.Chat.ReactNative/blob/bb59d980b23484a7897611de77d6847bcfad77f4/app/lib/methods/subscriptions/room.ts#L320
the creation and updates from the previous batch will be lost,
causing them to not reach the db.batch method.
As a result, Model._preparedState will remain in an executing state in memory and will never recover.
Consequently, this batch of messages will not receive any updates.
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 app/lib/methods/subscriptions/room.ts at the referenced message update handler, creation/update collection, timer, and db.batch calls. Trace the low-probability overlap between timer executions and the pending batch state, then reproduce it with a conversation containing message updates. Done means affected messages update normally and further conversation actions no longer produce the pending-changes error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react-native, typescript
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 39/100