Rocket.Chat.ReactNative
Rocket.Chat.ReactNative copied to clipboard
Cannot update a record with pending changes
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.