Open Bug 1850289 Opened 6 months ago Updated 3 months ago

onNewMailReceived listener unreliable

Categories

(Thunderbird :: Add-Ons: Extensions API, defect)

Thunderbird 115
defect

Tracking

(Not tracked)

UNCONFIRMED

People

(Reporter: jik, Unassigned)

References

(Depends on 1 open bug)

Details

I add a listener with messenger.messages.onNewMailReceived.addListener in my add-on when it loads. Then after adding the listener I scan all the messages currently in the user's inbox to catch any that were there before I added the listener. Nonetheless, I subsequently discovered that there are messages in the user's inbox that my add-on never saw, because they didn't show up in the scan of all messages in the folder and my listener was never called about them.

Jury's still out on whether the listener is unreliable in general or just during this startup period.

See Also: → 1824889

More data about this. I received an email at 17:57 tonight. It went into my inbox. Remote Content By Folder (my add-on) should have received a listener call about it. It never did.

My guess is that the message came in while my laptop was sleeping and for some reason the listener isn't being called on messages that come in when Thunderbird is "catching up" after being offline for a while. This may be the same reason why the listener isn't being called for messages that come in right when Thunderbird starts up.

(In reply to Jonathan Kamens from comment #1)

My guess is that the message came in while my laptop was sleeping and for some reason the listener isn't being called on messages that come in when Thunderbird is "catching up" after being offline for a while. This may be the same reason why the listener isn't being called for messages that come in right when Thunderbird starts up.

This could be related to bug 1850679.

See Also: → 1850679

@Jonathan: Are you using an OAUTH IMAP account (like GMAIL)? Are you able to reproduce this with a normal non-OAUTH IMAP account?

This is happening with a regular username/password IMAP account. On a Cyrus IMAPd server, specifically.

Every workaround I've tried for this problem has failed. It doesn't seem to be restricted to startup and offline -> online transitions. For whatever reason, I am frequently not getting notifications for all new messages that come into my inbox. The next theory I'm going to test when I have a few minutes to code it is that sometimes when multiple emails come in at the same time the notification doesn't include all of them. If that's the case then the workaround is going to be to rescan at least my entire inbox every time I get a notification.

Depends on: 1850679

Any news on solid steps to reproduce this issue? Is it also happening when the laptop was not sleeping?

Summary: onNewMailReceived listener unreliable → onNewMailReceived listener unreliable when
Summary: onNewMailReceived listener unreliable when → onNewMailReceived listener unreliable

I don't know anything more about why this is happening or how to reproduce it. All I can tell you is it seems to happen pretty often. I eventually gave up on relying on the events and coded my extension to scan folders regularly looking for messages it didn't get notified about.

As far as I can tell, the event is fired only if messages land in the Inbox folder, i.e. when messages aren't moved to other folders by filters.
According to the api docs this is not the expected behaviour

https://webextension-api.thunderbird.net/en/latest/messages.html#onnewmailreceived

Fired when a new message is received, and has been through junk classification and message filters.

As far as I can tell, the event is fired only if messages land in the Inbox folder

That's bug 1848787, which is different from this bug.

(In reply to Jonathan Kamens from comment #8)

As far as I can tell, the event is fired only if messages land in the Inbox folder

That's bug 1848787, which is different from this bug.

Hi Jonathan, no it isn't. That bug is about special folders other than Inbox. My complaint is about the reliability of onNewMailReceived for normal folders (i.e. subfolders of Inbox).
Why is the event not triggered if an email is received and a filter moves it to a subfolder of Inbox?

Well, if you don't think it's bug 1848787, fine, but it's not this bug. This bug is specifically about emails that absolutely should have been notified about, that don't fall into the filter problem you're mentioning, but notifications still weren't received.

If you're reliably seeing messages moved by filters not getting notified about, that's a different bug. I suggest you open a new bug for it.

(In reply to Jonathan Kamens from comment #10)

Well, if you don't think it's bug 1848787, fine, but it's not this bug. This bug is specifically about emails that absolutely should have been notified about, that don't fall into the filter problem you're mentioning, but notifications still weren't received.

If you're reliably seeing messages moved by filters not getting notified about, that's a different bug. I suggest you open a new bug for it.

Jonathan I see your point. I have followed your advice and opened a new bug 1864870.

You need to log in before you can comment on or make changes to this bug.