syncFolderUIDRange ErrorConnection on one of the folders

Problem

The sync fails on one of the folders. All other folders’ before this one sync finished with success.
The error in logs:

400260 [2021-02-01 09:48:50.382] [background] [info] syncFolderUIDRange for Redmine, UIDs: 1 - 57373, Heavy: false
400260 [2021-02-01 09:48:50.864] [background] [info] - remote=4366, local=0
400260 [2021-02-01 09:48:50.905] [background] [info] - Fetching full headers for 4366 (of 4366 needed)
400260 [2021-02-01 09:49:21.006] [background] [critical] 
***
*** Mailspring Sync 
*** An exception occurred during program execution: 
*** {"debuginfo":"syncFolderUIDRange - fetchMessagesByUID (heavy)","key":"ErrorConnection","retryable":true,"what":"std::exception"}
***

400260 [2021-02-01 09:49:21.006] [background] [critical] *** Stack trace (line numbers are approximate):
*** ??:?  SyncWorker::syncFolderUIDRange(Folder&, mailcore::Range, bool, vector*)
*** ??:?  SyncWorker::syncNow()
*** ??:?  runBackgroundSyncWorker()
*** ??:?  main::{lambda()#3}::operator()() const
*** ??:?  _Bind_simple::operator()()
*** ??:?  thread::_Impl::_M_run()
*** ??:?  execute_native_thread_routine()
***

Context

Can be produced always with particular folder, that has sub-folder in it (not sure if it is related).

Email Provider

Other IMAP, Zimbra

Setup

  • OS and Version: Fedora 33
    • Installation Method: .rpm
  • Mailspring Version: 1.8.0

Similar (same) issues

Looking through the linked issues above, this bug is not specific to any one email provider. It has been reported with Outlook, Gmail, IMAP, Zimbra, among others.

The common element is the crash message:

6207 [2019-01-12 17:43:18.299] [background] [critical] 
 ***
 *** A C++ exception occurred during program execution: 
 *** UNIQUE constraint failed: Folder.id
 ***

6207 [2019-01-12 17:43:18.302] [background] [critical]  *** Stack trace:
 ***   clone
 ***


This one is odd, because it apparently resolved itself, but I think it’s related:

I think I might have figured out what was causing it, at least on my end. I went through around 50k messages and moved 500 or at a time into new folders until it got to that folder and triggered the error again. I kept doing this until I had enough small batches to see which email looked a little weird.

Eventually I ran into an email where (somehow) the “to” email address in the header had this in it (I’ve changed the actual name but you can see the characters):

samuel;jackson"

That’s all it had for the “to”. So somehow some text in the header became corrupt over the years and there was a semicolon and a quote character in there where they shouldn’t have been.

I found 3 messages with the same thing. In my case they were from a Microsoft support ticket from 2013. I deleted all 3 messages (from server / webmail) and restarted Mailspring and it worked.

So this issue must have something to do with malformed headers containing unexpected characters. I can’t tell if it’s always been like this or just happened (my inbox has moved to several servers over the years).


(Originally posted by XGhozt on GitHub.)

1 Like

Not in this case.
I did run the moving out all emails (about 5k) from folder to local one, which made Mailspring sync very happy. Moving back all emails by batches (~500 emails at the time) didn’t cause any problems and all emails had been synced.

It is a pitty, but after successful sync, Zimbra // mailspring sync has been triggered and quite a bit of emails disappeared…

I’ve tried all of the above. Using Davmail works just fine with Thunderbird and other email apps, but not with Mailspiring. Here’s my error log.
385989 [2021-02-17 10:21:38.648] [metadata] [info] Metadata delta stream starting…
385989 [2021-02-17 10:21:41.648] [background] [info] Marking all folders as busy
385989 [2021-02-17 10:21:41.648] [background] [info] Syncing folder list…
385989 [2021-02-17 10:21:42.051] [background] [critical]


*** Mailspring Sync
*** A C++ exception occurred during program execution:
*** UNIQUE constraint failed: Folder.id


I am getting exactly the same issue.

Are there any updates on this yet?

1 Like

As a rule, all updates will be posted on the thread. If there are none posted, there are no updates. Your patience is appreciated. Mailspring is built and maintained by volunteers — even the core developer does this in addition to a full time job.

As a rule, asking for updates, status, or timeframe won’t hurry things along. If you want to help get a bug resolved or feature implemented quicker, here’s some things you can do, depending on your available time and skills:

  1. Vote. This raises the priority in planning. Anyone can do this.
  2. Help diagnose. Checking logs, testing out scenarios, or even digging around in the code if you’re up to the challenge all help move towards a resolution.
  3. Coordinate with other reporters. If you see similar bug reports, possible duplicates, or other posts with hints, helping get those individuals involved in diagnostics helps a lot!
  4. Attempting a PR. If you know anything about coding — even a little — you can check out the Mailspring source code from GitHub and try to fix the bug or implement the feature yourself. Even if you aren’t successful, or the fix isn’t ideal, the attempt still helps us!

And, of course, you can help just by being involved in the community: helping answer questions, triage bugs, and discuss features takes pressure off the developers, so they have time to focus on writing awesome code.

Hi guys,

I’m also hoping for an update. I’m searching for a replacement for Mail and Outlook on map for an IMAP account. Mailspring look great! However, being able to download all mail is an essential feature.

I too get the “syncFolderUIDRange - fetchMessagesByUID (heavy)” error.

I’m looking for this mail client for work and two others in our small business could benefit from it as well.

Let me know if I can help with logs.

Warmly,
Tyler

I wasn’t clear but I’m saying that we would gladly pay for a subscription(s) if this is fixed.

As a rule, all updates will be posted on the thread. If there are none posted, there are no updates. Your patience is appreciated. Mailspring is built and maintained by volunteers — even the core developer does this in addition to a full time job.

As a rule, asking for updates, status, or timeframe won’t hurry things along. If you want to help get a bug resolved or feature implemented quicker, here’s some things you can do, depending on your available time and skills:

  1. Vote. This raises the priority in planning. Anyone can do this.
  2. Help diagnose. Checking logs, testing out scenarios, or even digging around in the code if you’re up to the challenge all help move towards a resolution.
  3. Coordinate with other reporters. If you see similar bug reports, possible duplicates, or other posts with hints, helping get those individuals involved in diagnostics helps a lot!
  4. Attempting a PR. If you know anything about coding — even a little — you can check out the Mailspring source code from GitHub and try to fix the bug or implement the feature yourself. Even if you aren’t successful, or the fix isn’t ideal, the attempt still helps us!

And, of course, you can help just by being involved in the community: helping answer questions, triage bugs, and discuss features takes pressure off the developers, so they have time to focus on writing awesome code.

I’m reporting on the same issue. Pop_OS 22.04, mailspring 1.10.3, routing through davmail for exchange using EWS - IMAP connectivity. Thunderbird 91.8.0 works perfectly (but I really don’t prefer the thunderbird UI), connection through Mailspring fails. :frowning:

I don’t know where the Mailspring logs are stored. Please advise.

Hi there, I’m facing the exact same problem. Is the UNIQUE constraint error coming from the mailspirng sync repo (GitHub - Foundry376/Mailspring-Sync)? The error messages looks like it’s some constraint imposed by an internal database SQL? I’d be happy to have a look at what causes the error, but any pointer would be appreciated.

Hi,

same issue here, Exchange account via Davmail OWA.

*** Mailspring Sync
*** An exception occurred during program execution:
*** {“debuginfo”:“syncFolderUIDRange - fetchMessagesByUID”,“key”:“ErrorParse”,“retryable”:true,“what”:“std::exception”}


9272 [2024-09-27 07:15:59.035] [background] [critical] *** Stack trace (line numbers are approximate):
*** in mailsync SyncWorker::syncFolderUIDRange(Folder&, mailcore::Range, bool, vector*)
*** in mailsync SyncWorker::syncNow()
*** in mailsync runBackgroundSyncWorker()
*** in mailsync main::$_6::operator()() const
*** in mailsync decltype(declval()()) __invokeabi:ue170006
*** in mailsync void __thread_execute[abi:ue170006](tuple&, __tuple_indices)
*** in mailsync void* __thread_proxyabi:ue170006
*** 0x18fe08d34 thread_start()

272 [2024-09-27 07:13:56.155] [background] [info] --sleeping
9272 [2024-09-27 07:15:56.161] [background] [info] Syncing folder list…
9272 [2024-09-27 07:15:57.394] [background] [info] syncFolderUIDRange for INBOX, UIDs: 41931 - 51176, Heavy: false
9272 [2024-09-27 07:15:58.069] [background] [info] - INBOX: remote=400, local=400, remoteUID=f9MSDKgqMLHh7udEECb5QVxZdv42TXpsLyNiKqb6F
9272 [2024-09-27 07:15:58.477] [background] [info] syncFolderUIDRange for Sent, UIDs: 17909 - 18659, Heavy: true
9272 [2024-09-27 07:15:59.034] [background] [critical]

Only INBOX are syncing, all other folders (sent, trash, junk, custom folders) are stays in Scanning (0%) state.

I have gmail, outlook.com, hotmail, yahoo, own IMAP accounts, all of that are working now, I have issues only with Exchange account so if this would be fix than Mailspring would be a perfect email client.

thank you guys!