Hello everyone,
I see there is a similar post from last year here, related but not equal, that why I’m opening a new thread.
I have a sync task job that send messages to a specific conversation in our app according to some events triggered by an event listener.
As the title of this post, this is the error I’m getting when sending messages, even only sending 1 message. (sometimes yes, sometimes no).
I use the same function for the chat app we are building, and it works.
It’s just a duplicate function that send messages on behalf of the admin.
In the related post the problem came due to an index, but in my case I’m not using an index, as you can see below, I’m creating a new document and updating 1 at time.
conversationRef: Ref(Collection("conversations"), Var("id")),
messageDoc: If(Exists(Var("conversationRef")),
Create(Collection("messages"), {
data: {
conversation: Var("conversationRef"),
content: Select("message", Var("data")),
type: Select("type", Var("data")),
sentOn: ToTime(Select("eventTime", Var("data"), Now())),
author: Ref(Collection("users"), 0),
},
}), Abort("Conversation ref not found")),
updatedConversationDoc: Update(Var("conversationRef"), {
data: {
latestMessage: Select(["ref", "id"], Var("messageDoc")),
},
}),
The error looks like this:
responseRaw: '{"errors":[{"ref":{"@ref":{"id":"311798847832591111","collection":{"@ref":{"id":"conversations","collection":{"@ref":{"id":"collections"}}}}}},"code":"contended transaction","description":"Transaction was aborted due to detection of concurrent modification."}]}
The conversation exists, and I can send messages to it.
What could be the cause of this error here?
Thank you very much.