Closed Bug 1784047 Opened 3 years ago Closed 3 years ago

messageDisplay.getDisplayedMessages: Error: An unexpected error occurred when opened from an .eml file

Categories

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

Thunderbird 91
defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1644038

People

(Reporter: manikulin, Unassigned)

References

Details

Steps to reproduce:

I faced another issue when extension fails trying to get properties of a message shown in a messageDisplay window.

  • Open some message from an .eml file
  • Try to get shown message by calling browser.messageDisplay.getDisplayedMessages, e.g. load the following add-on and click on the message display action toolbar button

manifest.json

{
	"manifest_version": 2,
	"name": "Get Displayed Test",
	"version": "0.1",
	"permissions": [ "messagesRead" ],
	"background": { "scripts": [ "getdisp-bg.js" ] },
	"message_display_action": { "default_title": "Get Displayed Test" }
}

getdisp-bg.js

"use strict";

async function gdGetMessages(tab, info) {
	console.log("gdGetMessages: info, tab", info, tab);
	console.log("messageDisplay.getDisplayedMessages",
		await browser.messageDisplay.getDisplayedMessages(tab.id));
}

browser.messageDisplayAction.onClicked.addListener((tab, info) => { gdGetMessages(tab, info); });

Actual results:

Exception. Extension console:

 Uncaught (in promise) Error: An unexpected error occurred undefined
    gdGetMessages moz-extension://2e030f76-f418-4bc2-944e-463d4a5dea06/getdisp-bg.js:5
    AsyncFunctionThrow self-hosted:693
    (Async: async)
    <anonymous> moz-extension://2e030f76-f418-4bc2-944e-463d4a5dea06/getdisp-bg.js:9
    apply self-hosted:2733
    applySafeWithoutClone resource://gre/modules/ExtensionCommon.jsm:626
    fire resource://gre/modules/ExtensionChild.jsm:806
    withHandlingUserInput resource://gre/modules/ExtensionCommon.jsm:119
    recvRunListener resource://gre/modules/ExtensionChild.jsm:809
    recvRunListener self-hosted:1172
    _recv resource://gre/modules/ConduitsChild.jsm:78
    receiveMessage resource://gre/modules/ConduitsChild.jsm:184

browser console:

 msgHdr.getProperty is not a function ext-mail.js:1704
    convertMessage chrome://messenger/content/parent/ext-mail.js:1704
    getDisplayedMessages chrome://messenger/content/parent/ext-messageDisplay.js:25
    getDisplayedMessages chrome://messenger/content/parent/ext-messageDisplay.js:98
    getDisplayedMessages self-hosted:1172
    result resource://gre/modules/ExtensionParent.jsm:935
    withPendingBrowser resource://gre/modules/ExtensionParent.jsm:491
    result resource://gre/modules/ExtensionParent.jsm:935
    callAndLog resource://gre/modules/ExtensionParent.jsm:897
    recvAPICall resource://gre/modules/ExtensionParent.jsm:934
    InterpretGeneratorResume self-hosted:1479
    AsyncFunctionNext self-hosted:689

Messages obtained for Thunderbird-91, but thunderbird-105.0a1 has the same problem

Expected results:

Displayed message is reported to the add-on console:

messageDisplay.getDisplayedMessages 
Array [ {…} ]
getdisp-bg.js:5:10

I am working on bug 1644038 which is related to this. Currently the messages API has multiple issues with external messages.

Depends on: 1644038

@max : If you have some time, could you try if this build fixes it for you?
https://treeherder.mozilla.org/jobs?repo=try-comm-central&revision=2aad85ab2c7650786ca43bdd4dac37dbd6ede8d9

It includes the patch for bug 1644038.

(In reply to John Bieling (:TbSync) from comment #2)

@max : If you have some time, could you try if this build fixes it for you?
https://treeherder.mozilla.org/jobs?repo=try-comm-central&revision=2aad85ab2c7650786ca43bdd4dac37dbd6ede8d9

Unfortunately I can not figure out how to find a link to proper build artifact from treeherder. I guess, tomorrow daily build should contain this commit.

Oh, I am sorry. I somehow assumed you know how to get a build from treeherder. If you still want to try, click on the green "B" besides your platform and then switch to the "Artefacts" tab. For Linux this would get you here:
https://treeherder.mozilla.org/jobs?repo=try-comm-central&revision=2aad85ab2c7650786ca43bdd4dac37dbd6ede8d9&selectedTaskRun=bqQQuP3fRD-1t2s7v0cb8Q.0

In the list of files there is a "target.tar.bz2" file, which you can download & unpack and then run the thunderbird binary (either in root, in a bin or dist subfolder).

The patch still needs some work on review comments, so I do not know how long it will need till it reaches Daily.

(In reply to John Bieling (:TbSync) from comment #4)

Oh, I am sorry. I somehow assumed you know how to get a build from treeherder.

Previous time you just posted direct download link and I thought it is available for registered users only.

Thank you for your work on this issue.

  • I had to add a workaround to catch invalid Date object (out of range).
  • ccList' is filled, but recipients` array is empty.

This build should fix those errors as well:
https://treeherder.mozilla.org/jobs?repo=try-comm-central&revision=aee5ae22349906ef40647af492ec50790e2b05bf

It should now also work for inline messages (messages attached to other messages).

(In reply to John Bieling (:TbSync) from comment #6)

This build should fix those errors as well:
https://treeherder.mozilla.org/jobs?repo=try-comm-central&revision=aee5ae22349906ef40647af492ec50790e2b05bf

It should now also work for inline messages (messages attached to other messages).

Thank you I have not tested thoroughly, but date and recipients fields work in this commit.

It is unlikely related to changes for the Bug #1644038, but subject behaves in rather bizarre way. In Thunderbird-91 "Re:" is always stripped from MessageHeader.subject and it is inconvenient. I have not found any announced changes, but in latest versions subject in MessageHeader object mostly retains original "Re:" prefix. However I opened a message from an .eml file, saved a copy to local folders. Accessed directly, subject of this copy lost "Re:". If I attach this message and open the attachment then "Re:" is restored.

With your confirmation, that the two issues are fixed, I will close this bug as a duplicate. Feel free to post further findings related to those patches directly there.

For the subject issue, I had created Bug 1650140, but have not worked on yet. This is a good time to finally check that. Let us use it for discussing the current state of the subject (which includes the patches in Bug #1644038). I will repost your last comment there.

If you find any other bugs, please create a new one. Thanks for your debugging help.

Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.