RealRaven2000 / SmartTemplates

Thunderbird Add-on: SmartTemplates
http://smarttemplates.quickfolders.org/
Other
25 stars 15 forks source link

SmartTemplates for using latest Thunderbird Beta (128.0) #261

Open forke88 opened 9 months ago

forke88 commented 9 months ago

SmartTemplates are not working with lastest Beta.

Do you have plan to provide test version?

RealRaven2000 commented 9 months ago

Here is a bumped version - based on 4.2.1. Sorry I didn't get to test this one against the latest beta, if you find any problems, please leave them below and also write which Thunderbird version you use:

smartTemplate-fx-4.3pre1.zip


To install the version above, download the zip file and then drag the file into Thunderbird Add-ons Manager. Do not extract contents, it will not install that way. (Github does not allow xpi files in comments but technically a zip file is the same)

forke88 commented 9 months ago

Hi,

it looks like the extension does not work well in latest beta. I am using English (US) default version of Thunderbird, but all text/translations are broken and in config window i see "MSG_pref_serverdesc: MSG_pref_serverdef" etc.

Not able to test it further with broken texts :)

RealRaven2000 commented 9 months ago

Do you get error messages in javascript console when you open the settings window? I am using an experimental API from John Bieling from Thunderbird for localization.

Intructions for creating log: https://smarttemplates.quickfolders.org/support.html

forke88 commented 9 months ago

Yes, here are logs after opening settings window:

Uncaught NS_ERROR_FILE_NOT_FOUND: 
    <anonymous> chrome://smarttemplate4/content/smartTemplate-main.js:320
smartTemplate-main.js:320
Uncaught NS_ERROR_FILE_NOT_FOUND: 
    <anonymous> chrome://smarttemplate4/content/smartTemplate-util.js:13
smartTemplate-util.js:13
Uncaught NS_ERROR_FILE_NOT_FOUND: 
    <anonymous> chrome://smarttemplate4/content/smartTemplate-prefs.js:12
smartTemplate-prefs.js:12
Uncaught NS_ERROR_FILE_NOT_FOUND: 
    <anonymous> chrome://smarttemplate4/content/settings.js:12
settings.js:12
Uncaught TypeError: SmartTemplate4 is undefined
    <anonymous> chrome://smarttemplate4/content/smartTemplate-styles.js:166
smartTemplate-styles.js:166:2
Uncaught TypeError: SmartTemplate4 is undefined
    <anonymous> chrome://smarttemplate4/content/smartTemplate-help.js:14
smartTemplate-help.js:14:2
Uncaught NS_ERROR_FILE_NOT_FOUND: 
    <anonymous> chrome://smarttemplate4/content/smartTemplate-fileTemplates.js:15
smartTemplate-fileTemplates.js:15
Uncaught TypeError: SmartTemplate4 is undefined
    onselect chrome://smarttemplate4/content/settings.xhtml:1
    set selectedIndex chrome://global/content/elements/tabbox.js:236
    set selectedPanel chrome://global/content/elements/tabbox.js:246
    set selectedIndex chrome://global/content/elements/tabbox.js:599
    baseConnect chrome://global/content/elements/tabbox.js:543
    connectedCallback chrome://global/content/elements/tabbox.js:867
    <anonymous> chrome://global/content/customElements.js:211
settings.xhtml:1:1
Uncaught NS_ERROR_FILE_NOT_FOUND: 
    <anonymous> chrome://smarttemplate4/content/help.js:1
help.js:1
TypeError: window.SmartTemplate4 is undefined st-settings.js:6:16
RealRaven2000 commented 9 months ago

It looks like Services is already a global variable. I made some changes to work around this, but there are still some fundamental problems even loading the code at all. Going to check with John next week...

RealRaven2000 commented 9 months ago

What I have so far (to workaround the Services problem). I prefixed every line where I import Services like this:

if (typeof Services != "object") { 
  var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
}

smartTemplate-fx-4.3pre1.zip

but there are more problems to resolve, right at start up.

RealRaven2000 commented 9 months ago

Another version, I got the correct workaround code for forward compatibility from John Bieling:

var Services = globalThis.Services || ChromeUtils.import(
    "resource://gre/modules/Services.jsm"
    ).Services;

smartTemplate-fx-4.3pre2.zip

RealRaven2000 commented 9 months ago

TUrns out I can drop the complete Services declaration from Thunderbird 104 onwards. Since the current release has strict_min_ver = 115 I will drop it universally. Additional list of globals available from API scripts are listed here.

smartTemplate-fx-4.3pre4.zip


To install the version above, download the zip file and then drag the file into Thunderbird Add-ons Manager. Do not extract contents, it will not install that way. (Github does not allow xpi files in comments but technically a zip file is the same)

RealRaven2000 commented 9 months ago

Latest patch version, including changes for a number of issues (#264, #265, #266, [#263 WIP])

smartTemplate-fx-4.3pre30.zip


To install the version above, download the zip file and then drag the file into Thunderbird Add-ons Manager. Do not extract contents, it will not install that way. (Github does not allow xpi files in comments but technically a zip file is the same)

RealRaven2000 commented 5 months ago

Latest patch version, testable with Tb124.0b1, including changes related to #239, #246, #257, #267, #275, #276

smartTemplate-fx-4.4pre26.zip


To install the version above, download the zip file and then drag the file into Thunderbird Add-ons Manager. Do not extract contents, it will not install that way. (Github does not allow xpi files in comments but technically a zip file is the same)

RealRaven2000 commented 4 months ago

Latest version below compatible with Tb 125.*

smartTemplate-fx-4.4pre151.zip


To install the version above, download the zip file and then drag the file into Thunderbird Add-ons Manager. Do not extract contents, it will not install that way. (Github does not allow xpi files in comments but technically a zip file is the same)

RealRaven2000 commented 3 months ago

Latest version below compatible with Tb 126.*

smartTemplate-fx-4.5pre25.zip


To install version above download zip file and drag the file into Thunderbird Add-ons Manager (do not extract contents, it won't install like that)

RealRaven2000 commented 2 months ago

Latest version, with some important fixes for regular expressions - happy testing!

smartTemplate-fx-4.5pre57.zip


To install version above download zip file and drag the file into Thunderbird Add-ons Manager (do not extract contents, it won't install like that)

RealRaven2000 commented 2 months ago

Latest version below compatible with Tb 127.*

smartTemplate-fx-4.5.1pre3.zip


To install version above download zip file and drag the file into Thunderbird Add-ons Manager (do not extract contents, it won't install like that)

forke88 commented 2 months ago

Hi,

SmartTemplate stopped working with 127.*. It does not even open the context menu when clicking on the "SmartTemplates" button.

I have installed smartTemplate-fx-4.5.1pre3.zip (drag and drop zip file to the addons menu), but it didn't change anything. The extensions menu shows Version 4.5.1pre3 dated 24 May 2024.

RealRaven2000 commented 2 months ago

It worked for me with 127.0b1. Do you want to try the very latest build:

smartTemplate-fx-4.5.1pre11.zip

(Hope you downloaded the zip file) - here is what it looks like on 127.0b2. I am just working on converting the settings to show up in a tab as HTML - see issue #259.

image

forke88 commented 2 months ago

It looks like this for me:

In the second screenshot, when "SmartTemplates" is clicked, it shows a tiny ~2x10px gray bar on the bottom left of the button. I have already restarted Thunderbird few times and trries to install again with no luck.

1 2

Here are error logs when i deactivate and activate addon:


1716572569618   addons.webextension.smarttemplate4@thunderbird.extension    WARN    Loading extension 'smarttemplate4@thunderbird.extension': Reading manifest: Warning processing version: version must be a version string consisting of at most 4 integers of at most 9 digits without leading zeros, and separated with dots
Object { Util: {…}, Preferences: {…}, extractSignature: extractSignature(), insertTemplate: insertTemplate(), readSignatureFile: readSignatureFile(), resetDocument: resetDocument(), Parser: Parser(), composer: {}, Sig: {}, prefs: {…}, … }

Object { composers: Map(0) }
[st-background.js:9:9](moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/st-background.js)
test test2 [st-util.mjs.js:39:13](moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/scripts/st-util.mjs.js)
1716572569837   addons.webextension.smarttemplate4@thunderbird.extension    WARN    Loading extension 'smarttemplate4@thunderbird.extension': Reading manifest: Warning processing version: version must be a version string consisting of at most 4 integers of at most 9 digits without leading zeros, and separated with dots
1716572569842   addons.webextension.smarttemplate4@thunderbird.extension    WARN    Loading extension 'smarttemplate4@thunderbird.extension': Reading manifest: Warning processing version: version must be a version string consisting of at most 4 integers of at most 9 digits without leading zeros, and separated with dots
InternalError: too much recursion
[FolderLookupService.sys.mjs:71:29](resource:///modules/FolderLookupService.sys.mjs)
[Exception... "[JavaScript Error: "too much recursion" {file: "resource:///modules/FolderLookupService.sys.mjs" line: 71}]'[JavaScript Error: "too much recursion" {file: "resource:///modules/FolderLookupService.sys.mjs" line: 71}]' when calling method: [nsIFolderLookupService::getOrCreateFolderForURL]"  nsresult: "0x80570021 (NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)"  location: "<unknown>"  data: yes] [ExtensionCommon.sys.mjs:852](resource://gre/modules/ExtensionCommon.sys.mjs)
Uncaught (in promise) Error: An unexpected error occurred undefined
1716572570179   addons.webextension.smarttemplate4@thunderbird.extension    WARN    Loading extension 'smarttemplate4@thunderbird.extension': Reading manifest: Warning processing version: version must be a version string consisting of at most 4 integers of at most 9 digits without leading zeros, and separated with dots
1716572570185   addons.webextension.smarttemplate4@thunderbird.extension    WARN    Loading extension 'smarttemplate4@thunderbird.extension': Reading manifest: Warning processing version: version must be a version string consisting of at most 4 integers of at most 9 digits without leading zeros, and separated with dots

​```
RealRaven2000 commented 2 months ago

Thanks for posting the log, unfortunately it is too early, just click between the main and another tab and see what happens. Also, what about the button in the header view?

image

Can you open SmartTemplates settings from Add-ons Manager, or from the status bar icon:

image

if you can open Settings, make sure "mx parser" is not selected.

image

forke88 commented 2 months ago

I am not able to open SmartTemplates settings from Add-ons Manager (settings icon is disabled), and do not have SmartTemplates on status bar icon. Was able to do screenshot from "Debug Add-ons":

3 4

RealRaven2000 commented 2 months ago

By the way, I am not using FolderLookupService.sys.mjs directly but it might called by an API function. My guess something happens during looking at identities to match a SmartTemplates license... it needs to iterate all accounts:

js let accounts = await messenger.accounts.list(); It has an optional parameter that includes folder, see:

https://webextension-api.thunderbird.net/en/stable/accounts.html#list-includefolders Let me look it up and see whether we can alleviate that call by forcing it to ignore folders. I guess you have some broken folders or very many folders that time out when trying to pull them from an IMAP server.

Here is a version where I add the parameter includeFolders=false

smartTemplate-fx-4.5.1pre12.zip

Does this load better?

RealRaven2000 commented 2 months ago

I just double checked the code, but the call to messenger.accounts.list(); should not be called by the Licenser module, so it must be something else. Are you sure that mx parsers is switched off (that was an experimental part of SmartTemplates trying to rewrite the actual parser engine in composer as with web extension methods only, it is sadly incomplete).

Do you get any errors when you open ST settings from Add-ons Manager?

image

RealRaven2000 commented 2 months ago

OK, so the line (st-background.js:1093) that seems to throw is:

  await currentLicense.validate();

To get more info you can enable debug mode in about:config (Tb Setttings >> General >> Config Editor); search for the key smartTemplate4.debug and switch on:

extensions.smartTemplate4.debug = true
extensions.smartTemplate4.debug.premium.licenser = true

image

then clear the log and reload the add-on - this will give us more detail on where it is failing.

forke88 commented 2 months ago
Browser Console Mode
Parent process only(Fast)
Multiprocess(Slower)
1716584465535   addons.webextension.smarttemplate4@thunderbird.extension    WARN    Loading extension 'smarttemplate4@thunderbird.extension': Reading manifest: Warning processing version: version must be a version string consisting of at most 4 integers of at most 9 digits without leading zeros, and separated with dots
debuggee 'self-hosted:137' would run [utils.js:212:16](resource://devtools/server/actors/inspector/utils.js)
Object { Util: {…}, Preferences: {…}, extractSignature: extractSignature(), insertTemplate: insertTemplate(), readSignatureFile: readSignatureFile(), resetDocument: resetDocument(), Parser: Parser(), composer: {}, Sig: {}, prefs: {…}, … }

Object { composers: Map(0) }
[st-background.js:9:9](moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/st-background.js)
test test2 [st-util.mjs.js:39:13](moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/scripts/st-util.mjs.js)
validateLicense 
Object { LicenseKey: "COMMENTED_OUT" }
[st-util.mjs.js:34:15](moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/scripts/st-util.mjs.js)
RSA.initialise 35 [st-util.mjs.js:34:15](moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/scripts/st-util.mjs.js)
SmartTemplates Licenser
 Creating RSA key + decrypting [st-util.mjs.js:34:15](moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/scripts/st-util.mjs.js)
SmartTemplates Licenser
 get RSA.decryptedString() [st-util.mjs.js:34:15](moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/scripts/st-util.mjs.js)
1716584465635   addons.webextension.smarttemplate4@thunderbird.extension    WARN    Loading extension 'smarttemplate4@thunderbird.extension': Reading manifest: Warning processing version: version must be a version string consisting of at most 4 integers of at most 9 digits without leading zeros, and separated with dots
1716584465642   addons.webextension.smarttemplate4@thunderbird.extension    WARN    Loading extension 'smarttemplate4@thunderbird.extension': Reading manifest: Warning processing version: version must be a version string consisting of at most 4 integers of at most 9 digits without leading zeros, and separated with dots
Decryption Complete 
Object { RealLicense: "COMMENTED_OUT:2024-10-04" }
[st-util.mjs.js:34:15](moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/scripts/st-util.mjs.js)
InternalError: too much recursion
[FolderLookupService.sys.mjs:71:29](resource:///modules/FolderLookupService.sys.mjs)
    getOrCreateFolderForURL resource:///modules/FolderLookupService.sys.mjs:71
    get searchFolders/< resource:///modules/VirtualFolderWrapper.sys.mjs:125
    map self-hosted:175
    get searchFolders resource:///modules/VirtualFolderWrapper.sys.mjs:125
    getDirectSubfolders resource:///modules/ExtensionAccounts.sys.mjs:473
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:501
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
    traverseSubfolders resource:///modules/ExtensionAccounts.sys.mjs:513
[Exception... "[JavaScript Error: "too much recursion" {file: "resource:///modules/FolderLookupService.sys.mjs" line: 71}]'[JavaScript Error: "too much recursion" {file: "resource:///modules/FolderLookupService.sys.mjs" line: 71}]' when calling method: [nsIFolderLookupService::getOrCreateFolderForURL]"  nsresult: "0x80570021 (NS_ERROR_XPC_JAVASCRIPT_ERROR_WITH_DETAILS)"  location: "<unknown>"  data: yes] [ExtensionCommon.sys.mjs:852](resource://gre/modules/ExtensionCommon.sys.mjs)
    normalizeError resource://gre/modules/ExtensionCommon.sys.mjs:852
    recvAPICall resource://gre/modules/ExtensionParent.sys.mjs:1242
Uncaught (in promise) Error: An unexpected error occurred undefined
    main moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/st-background.js:1093
    AsyncFunctionThrow self-hosted:803
    (Async: async)
    <anonymous> moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/st-background.js:1465
1716584466235   addons.webextension.smarttemplate4@thunderbird.extension    WARN    Loading extension 'smarttemplate4@thunderbird.extension': Reading manifest: Warning processing version: version must be a version string consisting of at most 4 integers of at most 9 digits without leading zeros, and separated with dots
1716584466239   addons.webextension.smarttemplate4@thunderbird.extension    WARN    Loading extension 'smarttemplate4@thunderbird.extension': Reading manifest: Warning processing version: version must be a version string consisting of at most 4 integers of at most 9 digits without leading zeros, and separated with dots
RealRaven2000 commented 2 months ago

thanks I still think there is a problem running the API function message.accounts.list(false) - which simply shouldn't happen and would point to a bug in the API which @TbSync might be interested in. I added more debug log to make sure:

smartTemplate-fx-4.5.1pre13.zip

I would expect something like this (after Decryption Complete):


Decryption Complete 
Object { RealLicense: "S1-thunderbirddaily67@gmail.com:2025-02-16" }
[st-util.mjs.js:34:15](moz-extension://c963542e-dc45-4e01-bba8-99f012f6cc5e/scripts/st-util.mjs.js)
SmartTemplates Licenser
 Retrieve account WITHOUT FOLDERS... [st-util.mjs.js:34:15](moz-extension://c963542e-dc45-4e01-bba8-99f012f6cc5e/scripts/st-util.mjs.js)
Found 2 Accounts 
Array [ {…}, {…} ]
[st-util.mjs.js:34:15](moz-extension://c963542e-dc45-4e01-bba8-99f012f6cc5e/scripts/st-util.mjs.js)
SmartTemplates Licenser
 Iterate accounts to check default Identities... [st-util.mjs.js:34:15](moz-extension://c963542e-dc45-4e01-bba8-99f012f6cc5e/scripts/st-util.mjs.js)
premium.licenser 
Object { "Iterate accounts": "thunderbirddaily67@gmail.com", "Default Identity": "id1" }
[st-util.mjs.js:34:15](moz-extension://c963542e-dc45-4e01-bba8-99f012f6cc5e/scripts/st-util.mjs.js)
Default Identity of this account matched! 
Object { account: "thunderbirddaily67@gmail.com", identity: "thunderbirddaily67@gmail.com", status: "Valid" }

If the last thing before the exception is "Retrieve account WITHOUT FOLDERS" then we will know...

it also means that any other extension that uses messenger.accounts.list() fails on your profile (that would also include my Add-ons QuickFolders and quickFilters which use the same licensing algorithm). One of the accounts is probably broken.

forke88 commented 2 months ago

smartTemplate-fx-4.5.1pre13.zip fixed the problem and everything works fine now. I have no other extensions as you see on previous screen. Only SmartTemplates and "System theme - auto" but it is visible only in addons debug, not able to remove it.

Debug log after enabling the extension:

1716620177345   addons.webextension.smarttemplate4@thunderbird.extension    WARN    Loading extension 'smarttemplate4@thunderbird.extension': Reading manifest: Warning processing version: version must be a version string consisting of at most 4 integers of at most 9 digits without leading zeros, and separated with dots
debuggee 'self-hosted:137' would run [utils.js:212:16](resource://devtools/server/actors/inspector/utils.js)
Object { Util: {…}, Preferences: {…}, extractSignature: extractSignature(), insertTemplate: insertTemplate(), readSignatureFile: readSignatureFile(), resetDocument: resetDocument(), Parser: Parser(), composer: {}, Sig: {}, prefs: {…}, … }

Object { composers: Map(0) }
[st-background.js:9:9](moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/st-background.js)
test test2 [st-util.mjs.js:39:13](moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/scripts/st-util.mjs.js)
validateLicense 
Object { LicenseKey: "COMMENTED_OUT" }
[st-util.mjs.js:34:15](moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/scripts/st-util.mjs.js)
RSA.initialise 35 [st-util.mjs.js:34:15](moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/scripts/st-util.mjs.js)
SmartTemplates Licenser
 Creating RSA key + decrypting [st-util.mjs.js:34:15](moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/scripts/st-util.mjs.js)
SmartTemplates Licenser
 get RSA.decryptedString() [st-util.mjs.js:34:15](moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/scripts/st-util.mjs.js)
1716620177439   addons.webextension.smarttemplate4@thunderbird.extension    WARN    Loading extension 'smarttemplate4@thunderbird.extension': Reading manifest: Warning processing version: version must be a version string consisting of at most 4 integers of at most 9 digits without leading zeros, and separated with dots
1716620177443   addons.webextension.smarttemplate4@thunderbird.extension    WARN    Loading extension 'smarttemplate4@thunderbird.extension': Reading manifest: Warning processing version: version must be a version string consisting of at most 4 integers of at most 9 digits without leading zeros, and separated with dots
Decryption Complete 
Object { RealLicense: "COMMENTED_OUT:2024-10-04" }
[st-util.mjs.js:34:15](moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/scripts/st-util.mjs.js)
SmartTemplates Licenser
 Retrieve account WITHOUT FOLDERS... [st-util.mjs.js:34:15](moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/scripts/st-util.mjs.js)
Found 7 Accounts 
Array(7) [ {…}, {…}, {…}, {…}, {…}, {…}, {…} ]
[st-util.mjs.js:34:15](moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/scripts/st-util.mjs.js)
SmartTemplates Licenser
 Iterate accounts to check default Identities... [st-util.mjs.js:34:15](moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/scripts/st-util.mjs.js)
premium.licenser 
Object { "Iterate accounts": "COMMENTED_OUT", "Default Identity": "id3" }
[st-util.mjs.js:34:15](moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/scripts/st-util.mjs.js)
Default Identity of this account matched! 
Object { account: "COMMENTED_OUT", identity: "COMMENTED_OUT", status: "Valid" }
[st-util.mjs.js:34:15](moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/scripts/st-util.mjs.js)
Returning Grace Period Date: 2023-10-01 [st-background.js:1049:26](moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/st-background.js)
Finished setting up license startup code [st-background.js:1099:24](moz-extension://c111d910-4929-45b2-b4b7-61894db76e29/st-background.js)
Please use ChromeUtils.defineLazyGetter instead of XPCOMUtils.defineLazyGetter. XPCOMUtils.defineLazyGetter will be removed soon. 4 [XPCOMUtils.sys.mjs:47:13](resource://gre/modules/XPCOMUtils.sys.mjs)
SmartTemplates [logTime init]
 st-messenger - onLoad(true)... [smartTemplate-util.js:729:13](chrome://smarttemplate4/content/smartTemplate-util.js)
SmartTemplates 8:56:17.539  [1 ms]   
 Util.init... [smartTemplate-util.js:729:13](chrome://smarttemplate4/content/smartTemplate-util.js)
SmartTemplates 8:56:17.567  [28 ms]  
 startUp... [smartTemplate-util.js:729:13](chrome://smarttemplate4/content/smartTemplate-util.js)
SmartTemplates 8:56:17.568  [1 ms]   
 startUp complete [smartTemplate-util.js:729:13](chrome://smarttemplate4/content/smartTemplate-util.js)
SmartTemplates 8:56:17.568  [0 ms]   
 loadCustomMenu(false)... [smartTemplate-util.js:729:13](chrome://smarttemplate4/content/smartTemplate-util.js)
SmartTemplates 8:56:17.569  [1 ms]   
 loadCustomMenu() - Success [smartTemplate-util.js:729:13](chrome://smarttemplate4/content/smartTemplate-util.js)
SmartTemplates 8:56:17.569  [0 ms]   
 loadMRU() [smartTemplate-util.js:729:13](chrome://smarttemplate4/content/smartTemplate-util.js)
Please use ChromeUtils.defineLazyGetter instead of XPCOMUtils.defineLazyGetter. XPCOMUtils.defineLazyGetter will be removed soon. 4 [XPCOMUtils.sys.mjs:47:13](resource://gre/modules/XPCOMUtils.sys.mjs)
SmartTemplates 8:56:17.576  [7 ms]   
 ============INJECT==========
st-messagePane.js onLoad(true) [smartTemplate-util.js:729:13](chrome://smarttemplate4/content/smartTemplate-util.js)
Please use ChromeUtils.defineLazyGetter instead of XPCOMUtils.defineLazyGetter. XPCOMUtils.defineLazyGetter will be removed soon. 4 [XPCOMUtils.sys.mjs:47:13](resource://gre/modules/XPCOMUtils.sys.mjs)
SmartTemplates 8:56:17.577  [1 ms]   
 ============INJECT==========
st-messagePane.js onLoad(true) [smartTemplate-util.js:729:13](chrome://smarttemplate4/content/smartTemplate-util.js)
Please use ChromeUtils.defineLazyGetter instead of XPCOMUtils.defineLazyGetter. XPCOMUtils.defineLazyGetter will be removed soon. 4 [XPCOMUtils.sys.mjs:47:13](resource://gre/modules/XPCOMUtils.sys.mjs)
SmartTemplates 8:56:17.587  [10 ms]  
 ============INJECT==========
st-messagePane.js onLoad(true) [smartTemplate-util.js:729:13](chrome://smarttemplate4/content/smartTemplate-util.js)
Please use ChromeUtils.defineLazyGetter instead of XPCOMUtils.defineLazyGetter. XPCOMUtils.defineLazyGetter will be removed soon. 4 [XPCOMUtils.sys.mjs:47:13](resource://gre/modules/XPCOMUtils.sys.mjs)
SmartTemplates 8:56:17.588  [1 ms]   
 ============INJECT==========
st-messagePane.js onLoad(true) [smartTemplate-util.js:729:13](chrome://smarttemplate4/content/smartTemplate-util.js)
Please use ChromeUtils.defineLazyGetter instead of XPCOMUtils.defineLazyGetter. XPCOMUtils.defineLazyGetter will be removed soon. 4 [XPCOMUtils.sys.mjs:47:13](resource://gre/modules/XPCOMUtils.sys.mjs)
SmartTemplates 8:56:17.590  [2 ms]   
 ============INJECT==========
st-messagePane.js onLoad(true) [smartTemplate-util.js:729:13](chrome://smarttemplate4/content/smartTemplate-util.js)
Please use ChromeUtils.defineLazyGetter instead of XPCOMUtils.defineLazyGetter. XPCOMUtils.defineLazyGetter will be removed soon. 4 [XPCOMUtils.sys.mjs:47:13](resource://gre/modules/XPCOMUtils.sys.mjs)
SmartTemplates 8:56:17.591  [1 ms]   
 ============INJECT==========
st-messagePane.js onLoad(true) [smartTemplate-util.js:729:13](chrome://smarttemplate4/content/smartTemplate-util.js)
Please use ChromeUtils.defineLazyGetter instead of XPCOMUtils.defineLazyGetter. XPCOMUtils.defineLazyGetter will be removed soon. 4 [XPCOMUtils.sys.mjs:47:13](resource://gre/modules/XPCOMUtils.sys.mjs)
SmartTemplates 8:56:17.592  [1 ms]   
 ============INJECT==========
st-messagePane.js onLoad(true) [smartTemplate-util.js:729:13](chrome://smarttemplate4/content/smartTemplate-util.js)
Please use ChromeUtils.defineLazyGetter instead of XPCOMUtils.defineLazyGetter. XPCOMUtils.defineLazyGetter will be removed soon. 4 [XPCOMUtils.sys.mjs:47:13](resource://gre/modules/XPCOMUtils.sys.mjs)
SmartTemplates 8:56:17.593  [1 ms]   
 ============INJECT==========
st-messagePane.js onLoad(true) [smartTemplate-util.js:729:13](chrome://smarttemplate4/content/smartTemplate-util.js)
Please use ChromeUtils.defineLazyGetter instead of XPCOMUtils.defineLazyGetter. XPCOMUtils.defineLazyGetter will be removed soon. 4 [XPCOMUtils.sys.mjs:47:13](resource://gre/modules/XPCOMUtils.sys.mjs)
SmartTemplates 8:56:17.593  [0 ms]   
 ============INJECT==========
st-messagePane.js onLoad(true) [smartTemplate-util.js:729:13](chrome://smarttemplate4/content/smartTemplate-util.js)
Please use ChromeUtils.defineLazyGetter instead of XPCOMUtils.defineLazyGetter. XPCOMUtils.defineLazyGetter will be removed soon. 4 [XPCOMUtils.sys.mjs:47:13](resource://gre/modules/XPCOMUtils.sys.mjs)
SmartTemplates 8:56:17.612  [19 ms]  
 ============INJECT==========
st-messagePane.js onLoad(true) [smartTemplate-util.js:729:13](chrome://smarttemplate4/content/smartTemplate-util.js)
Please use ChromeUtils.defineLazyGetter instead of XPCOMUtils.defineLazyGetter. XPCOMUtils.defineLazyGetter will be removed soon. 4 [XPCOMUtils.sys.mjs:47:13](resource://gre/modules/XPCOMUtils.sys.mjs)
SmartTemplates 8:56:17.613  [1 ms]   
 ============INJECT==========
st-messagePane.js onLoad(true) [smartTemplate-util.js:729:13](chrome://smarttemplate4/content/smartTemplate-util.js)
Please use ChromeUtils.defineLazyGetter instead of XPCOMUtils.defineLazyGetter. XPCOMUtils.defineLazyGetter will be removed soon. 4 [XPCOMUtils.sys.mjs:47:13](resource://gre/modules/XPCOMUtils.sys.mjs)
SmartTemplates 8:56:17.662  [49 ms]  
 ============INJECT==========
st-messagePane.js onLoad(true) [smartTemplate-util.js:729:13](chrome://smarttemplate4/content/smartTemplate-util.js)
1716620177700   addons.webextension.smarttemplate4@thunderbird.extension    WARN    Loading extension 'smarttemplate4@thunderbird.extension': Reading manifest: Warning processing version: version must be a version string consisting of at most 4 integers of at most 9 digits without leading zeros, and separated with dots
1716620177706   addons.webextension.smarttemplate4@thunderbird.extension    WARN    Loading extension 'smarttemplate4@thunderbird.extension': Reading manifest: Warning processing version: version must be a version string consisting of at most 4 integers of at most 9 digits without leading zeros, and separated with dots
SmartTemplates initMenusWithReset()
 chrome://messenger/content/messenger.xhtml singleMessags=false  menu patched via API: true [smartTemplate-util.js:773:12](chrome://smarttemplate4/content/smartTemplate-util.js)
SmartTemplates 8:56:17.776  [114 ms]     
 fileTemplates.initMenus(reset=true) ...

Object { toolbarType: "unified" }
[smartTemplate-util.js:729:13](chrome://smarttemplate4/content/smartTemplate-util.js)
SmartTemplates 8:56:19.717  [1941 ms]    
 SmartTemplate4.updateStatusBar(default) ... with licenseInfo =  
Object { status: "Valid", description: "Valid", licensedDaysLeft: 132, expiredDays: 0, expiryDate: "2024-10-04", email: "COMMENTED_OUT", licenseKey: "COMMENTED_OUT", decryptedPart: "COMMENTED_OUT:2024-10-04", keyType: 0, isValid: true, … }
[smartTemplate-util.js:729:13](chrome://smarttemplate4/content/smartTemplate-util.js)
RealRaven2000 commented 2 months ago

Interesting… we should have seen this working with pre12 already (i changed the parameter for accounts.list() there already to not include folders. The only other changes in pre13 where additional log lines.

This is still valuable as it shows there is a problem with the folder structure on one of your accounts that causes an exception in the account iterator. May I pass this on to a Thunderbird dev, maybe they can add some more meaningful message to at least show in which account the error happens, and possibly which folder was the last successful read? ultimately this would be worth creating a bug on Bugzilla. I believe you can easily recreate the problem from the Add-ons console ( debug addons / inspect) from any Add-on,(i think it must have accounts permission though) just by going to console and typing:

await browser.accounts.list();

by default this will iterate all accounts including all folders. If this throws, try again with:

await browser.accounts.list(false);

RealRaven2000 commented 2 months ago

Example for accounts.list():

image

as you see this returns an array of folders for each of the accounts, I guess this is what fails on your system.

forke88 commented 2 months ago

Yes, you are right:

await browser.accounts.list();
Uncaught (in promise) Error: An unexpected error occurred undefined
await browser.accounts.list(false);
Array(7) [ {…}, {…}, {…}, {…}, {…}, {…}, {…} ]

So it looks like the problem is with folders structure? Is there any way to find which one is failing? Have dozens of them. Then maybe i can drop it and re-fetch from IMAP from scratch?

RealRaven2000 commented 2 months ago

I spent all afternoon writing a function to test performance impact of many folders it turns out it took about 1335ms for a total of 1485 folders on my production mail profile. So it's definitely significant enough to add that parameter to all my Add-ons, even if they don't have the bug you discovered.

Here is the function I made to sum up the total number of folders for every account recursively:

async function testCountFolders(includeFolders = false, debug = false){ 
  let mAccounts = await messenger.accounts.list(includeFolders);
  let fCount = 0;

  if (includeFolders) {
    function countSubFolders(f) {
      if (!f) return 0;
      if (!f.subFolders || !f.subFolders.length) return 1;
      try {
        return f.subFolders.reduce(
          (n, fld) => {
            let ct = countSubFolders(fld);
            return n + ct;
          },  1
        )
      }
      catch(ex) {
        console.log("exception in " + f.name)
        return 0;
      }
    }
    fCount = mAccounts.reduce( (n, ac) => {
      let subCount = ac.folders.reduce( (m, fld) => {
            let csf = countSubFolders(fld);
            if (typeof m + csf == "undefined") {
              debugger;
            }
            return m + csf;

          }, 0
      );
      let val = n + subCount // ac.folders.length +

      if (debug) { 
        console.log(`ACCOUNT ${ac.name} : ${subCount} + ${n}`);
      }
      return val;

    }, 0);
  }  
  if (debug) { 
    console.log("TOTAL FOLDERS: " + fCount);
  }
  return fCount;
};

I guess that the accounts.list() function fills all the "subFolders" parts recursively too to generate the information in MailAccount.subFolders

RealRaven2000 commented 1 month ago

Latest test version, compatible with beta 128 - which is close to the final release of Thunderbird ESR 128.0 planned for this summer.

This version has the current work from #259 in it - to try out the new settings dialog, you can use the config switch extensions.smartTemplate4.settings.html = true (more detail over at the bug)

smartTemplate-fx-4.6pre57.zip


To install the version above, download the zip file and then drag the file into Thunderbird Add-ons Manager. Do not extract contents, it will not install that way.

RealRaven2000 commented 1 month ago

Latest version, compatible with Tb 128.*, tested on current beta 128.0b3. This also fixes issue #295.

smartTemplate-fx-4.6pre68.zip


To install the version above, download the zip file and then drag the file into Thunderbird Add-ons Manager. Do not extract contents, it will not install that way.

RealRaven2000 commented 2 weeks ago

Here is the very very latest version, which already activates the brand new html settings dialog of issue #259:

smartTemplate-fx-4.6pre77.zip

This version will soon be finalized for release - the main thing missing is an up to date, localized change log.


To install the version above, download the zip file and then drag the file into Thunderbird Add-ons Manager. Do not extract contents, it will not install that way.

RealRaven2000 commented 1 week ago

Very latest version here:

smartTemplate-fx-4.6pre87.zip

Settings will now open in a tab even when using the "wrench" icon in Add-ons manager. Also change log is now fully translated and shows on the splash screen.

image


To install the version above, download the zip file and then drag the file into Thunderbird Add-ons Manager. Do not extract contents, it will not install that way.