Closed Bug 1975854 Opened 7 months ago Closed 2 months ago

compose.onAfterSend not always called

Categories

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

Thunderbird 140
defect

Tracking

(Not tracked)

RESOLVED FIXED
147 Branch

People

(Reporter: G.Gersdorf, Assigned: john)

References

Details

Attachments

(3 files, 1 obsolete file)

Steps to reproduce:

Have two add-ons which adds a listener for compose.onAfterSend

Actual results:

Only one listener is called. The other fails in the onSuccess block on the line
https://searchfox.org/comm-central/source/mail/components/extensions/parent/ext-compose.js#1474
TB than continues to the onFailure block but also fails at the same statement.

Expected results:

Both listeners should be called.

This bug prevents two of my add-ons from coexisting...

Thanks for the report, Günter. Which two add-ons are that? Could you check this in Daily, if it may have been fixed by bug 1959939? I changed the order of some calls, which were different compared to the onBeforeSend event.

Attached file testOnAfterSend1.xpi
Attached file testOnAfterSend2.xpi

Tested with daily 2025-11-16 and fresh profile: No change, only one add-on is called.
I've tested with two nearly identical minimal add-ons, see attachments. Only the console message from the first installed add-on is shown.

Status: UNCONFIRMED → NEW
Ever confirmed: true
Blocks: 1959939
Attached file WIP: Bug 1975854 (obsolete) —
Attachment #9527089 - Attachment is obsolete: true

The compose window may be destroyed while the event result is still being
prepared asynchronously, which could cause some listeners to not notify
their handlers.

This patch introduces the onConvertSync callback, which is executed while
the compose window is guaranteed to exist. Because this callback must be
called from inside MsgOperationObserver, the calls to the other callbacks
(onSuccess and onFailure) have also been moved there.

Assignee: nobody → john
Status: NEW → ASSIGNED

Will this approach garantee that information i have added to the compose window via messenger.sessions.setTabValue() are accessible in the onAfterSend listener?

I don't think so, the window is probably destroyed by the time onAfterSend is called, which is the reason why the current implementation of the event fails for your second extension.

Edit: I added a note to the documentation.

Pushed by benc@thunderbird.net:
https://hg.mozilla.org/comm-central/rev/4c95576f4aaf
Fix race condition when multiple extensions register a listener for the compose.onAfterSend event. r=mkmelin

Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 147 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: