Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App states regular_low and regular_high not syncing after archiving chat #518

Open
MiguelArgentina opened this issue Dec 13, 2023 · 7 comments

Comments

@MiguelArgentina
Copy link

In our app we are trying to add the archive chat feature for every message we send.
The first time we archive the chat, it works, but after that, every other message sent fails archiving with the errors shown below.
This is a part of the function where the message is sent and archived:

        userJID := types.NewJID(phoneNumber, types.DefaultUserServer)
	message := &waProto.Message{
		Conversation: proto.String(messageContent),
	}
        ctx := context.Background()
	resp, err := client.SendMessage(ctx, userJID, message)
	chatID := resp.ID
	messageTimeStamp := resp.Timestamp
	lastMessageKey := &waProto.MessageKey{
		RemoteJid: proto.String(userJID.String()),
		FromMe:    proto.Bool(true),
		Id:        proto.String(chatID),
	}
	archiveChat := true

        archivePatch := appstate.BuildArchive(userJID, *proto.Bool(archiveChat), messageTimeStamp, lastMessageKey)
        err = client.SendAppState(archivePatch)

And these are the errors shown in the logs when client.SendAppState(archivePatch) is executed:

<?xml version="1.0"?>
<collection has_more_patches="true" name="regular_low" type="error">
  <error code="409" text="conflict"/>
  <patches>
    <patch><!-- 867 bytes --></patch>
    <patch><!-- 1175 bytes --></patch>
    <patch><!-- 1021 bytes --></patch>
    <patch><!-- 1313 bytes --></patch>
    <patch><!-- 1329 bytes --></patch>
    <patch><!-- 1021 bytes --></patch>
    <patch><!-- 1021 bytes --></patch>
    <patch><!-- 1021 bytes --></patch>
   ...
  </patches>
</collection>

I also tried resyncing the patches (before archiving) with:

        for _, name := range appstate.AllPatchNames {
		err := client.FetchAppState(name, true, false)
		if err != nil {
			client.Log.Errorf("Failed to do initial fetch of app state %s: %v", name, err)
		}
	}

but I get these two errors:

[Client ERROR] Failed to do initial fetch of app state regular_high: failed to decode app state regular_high patches: failed to verify patch v897: mismatching LTHash

and

[Client ERROR] Failed to do initial fetch of app state regular_low: failed to decode app state regular_low patches: failed to verify patch v712: mismatching LTHash

Does anyone have a tip on what this could be?
Maybe I should recalculate the LTHash? If this is the case, how can I do it?

@MiguelArgentina MiguelArgentina changed the title App states regualr_low and regular_high not syncing after archiving chat App states regular_low and regular_high not syncing after archiving chat Dec 13, 2023
@lairhas
Copy link

lairhas commented May 5, 2024

I had the same issues @MiguelArgentina. After investigations, I think it has something to do with app_state_version in the db and app_state_version stored in other device. If one of them has flaw app_state_version, it will affect all devices with the same JID.

My quick fix was disconnecting all devices that connect to my WhatsApp and deleting the db.

@MiguelArgentina
Copy link
Author

I had the same issues @MiguelArgentina. After investigations, I think it has something to do with app_state_version in the db and app_state_version stored in other device. If one of them has flaw app_state_version, it will affect all devices with the same JID.

My quick fix was disconnecting all devices that connect to my WhatsApp and deleting the db.

Thanks a lot for sharing! I'll have this in mind. The thing is that we have close to 100 users, and deleting the DB would be something to avoid.

@mateusfmello
Copy link

Any solution for this error?

@brunoaduarte
Copy link

brunoaduarte commented Aug 29, 2024

I got a similar issue #651

Disconnecting the linked device and rescanning the QR code does not fix the issue, as the patches come from the main device.

It all started after I created a label using a linked WhatsApp Web device.

A created many labels before, but always using the main device. Problem only started after the label was created on the web version. In my case It's stuck on patch 563.

@lairhas
Copy link

lairhas commented Aug 29, 2024 via email

@brunoaduarte
Copy link

brunoaduarte commented Aug 29, 2024

Have you disconnected all linked devices from the device?

No I hadn't tried that before. As there were other linked devices being used I didn't bother doing that.
But now I followed your suggestion: erased all linked devices and it seems the issue is gone.

Although it's just a quickfix, the bug still persists.

Thanks for the tip!

@mateusfmello
Copy link

In fact, reconnecting resolves the lack of synchronization...

However, the problem persists and may return at any time.
We need to find the source of the error to fix the problem once and for all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants