vladimiry / ElectronMail

Unofficial ProtonMail Desktop App
GNU General Public License v3.0
1.48k stars 96 forks source link

"Message does not exist" #661

Open RobertKirchner9 opened 7 months ago

RobertKirchner9 commented 7 months ago

This is not an existential threat to my well-being, just a mild annoyance, but ElectronMail, since the last update, has been intermittently flashing a red warning, "Message does not exist". The warning appears at random moments and seems to have no consequences.

vladimiry commented 7 months ago

If you have the local store option enabled for the mail account, it might potentially be that Proton has changed some internals that the app's "local store" feature didn't take into the account doing mails syncing. I didn't notice the listed warning at my side though yet.

ylluminarious commented 3 months ago

I've noticed this problem as well, but it seems to only be on a single account and not others.

I'd be happy to help diagnose this further if necessary @vladimiry

ylluminarious commented 2 months ago

@vladimiry I noticed this error occurring again on the same account, and I simultaneously noticed the following messages in log.log:

[2024-05-04 22:29:04.508] [error] src/electron-preload/webview/lib/const.ts [preload: webview/primary] src/electron-preload/webview/primary/api/db-patch/index.ts buildDbPatchRetryPipeline {
  name: 'StatusCodeError',
  message: 'Message does not exist',
  status: 422,
  responseUrl: 'https://mail-api.proton.me/mail/v4/messages/<wiped-out>',
  responseStatusText: '',
  dataCode: 2501,
  dataError: 'Message does not exist'
}
[2024-05-04 22:29:04.509] [error] src/electron-preload/webview/lib/const.ts [preload: webview/primary] src/electron-preload/webview/primary/api/index.ts [pubsub-to-rpc-api] [provider] notification.error {"name":"buildDbPatch","channel":"electron-mail:webview-api:primary","payloadType":"request","uid":"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"} {
  name: 'StatusCodeError',
  message: 'Message does not exist',
  status: 422,
  responseUrl: 'https://mail-api.proton.me/mail/v4/messages/<wiped-out>',
  responseStatusText: '',
  dataCode: 2501,
  dataError: 'Message does not exist'
}

Does that help shed any light on what the root cause of this issue is?

ylluminarious commented 2 months ago

@vladimiry Another thing I noticed when re-examining this issue is that all of the messages in the local store for this account are extremely out-of-date, when compared to the current messages in the online store. The newest messages in the local store are from about 6 months ago, which is when the latest ElectronMail update came out. It seems that no new messages have been getting saved in the local store since that time...

Perhaps this issue could be mitigated if we could somehow delete the entire local store for this specific account and then trigger a totally fresh re-sync of the local store from the online store?

Is it possible to surgically purge the local store of a singular account without deleting the corresponding messages from the actual online account?

vladimiry commented 2 months ago

The app should re-sync the messages, regardless how old the local data is, and I believe it was trying to do so, but faced the Message does not exist error for some reason. Apparently, some time ago, Proton changed something that the app didn't take into the account. This error is not added to the "recoverable" list in the app, and so messages sync process never completes (and starts again each time). Technically, the app is not supposed to download non-existing messages, and it was so before.

The workaround is adding this error to the "recoverable" list for the sync process, so the error gets skipped and process continuous. This would be a dirty, but probably valid hack for this case at this time. But a proper option is to make the app not to download such "shadow messages", which would be hard to do not knowing what exactly was changed by Proton.

Perhaps this issue could be mitigated if we could somehow delete the entire local store for this specific account and then trigger a totally fresh re-sync of the local store from the online store?

Worth trying. The "local store" is a per-account feature. So you could disable this toggle for the problematic account, restart the app (the "local store"-related data will be removed for this account at the app startup), and enable it again.

Adding "provider change" label as this error didn't occur before and only started to happen with recent app update. The app itself didn't change the related/syncing logic.

ylluminarious commented 2 months ago

@vladimiry Thank you very much for clarifying the nature of this bug. That makes a lot more sense now.

Regarding your suggested workaround:

... you could disable this toggle for the problematic account, restart the app (the "local store"-related data will be removed for this account at the app startup), and enable it again.

I went ahead and tried what you suggested here, and I can confirm that this indeed works. It re-created my local store for the problematic account and now I see that the local store is matching the online store.

Thanks so much for the suggestion. It seems this workaround is sufficient for my needs at present until a more permanent fix can be implemented here.