During investigation of bug 1018828 code reading suggests that we probably call markSyncRange in the IMAP case regardless of whether there is an error or not. We definitely don't have a unit test that verifies lastSyncedAt does not change in the failure case. I'll add a unit test and assuming that proves we are broken, I'll fix the bug. If the test says we're fine, I'll add some comments so subsequent code reading does not get misled too. POP3 may or may not be affected by something similar; I'm filing a bug for that one, and it may or may not be able to rely on new test coverage from this bug.