Extended-Thunder / send-later

Schedule messages to be sent at a specific time.
Mozilla Public License 2.0
123 stars 17 forks source link

Restore execution order related to compactDrafts() #724

Closed jobisoft closed 3 months ago

jobisoft commented 4 months ago

Commit https://github.com/Extended-Thunder/send-later/commit/fd3d19bab2f0bb945747b4d211f6e6356e5fa7bb introduced a delay to mitigate Bug 1909111.

The change adds a delay before compacting, which resolves the error reported to this project, which is primarily caused by the mentioned underlying Thunderbird bug.

That commit changed the execution flow: The used setTimeout() causes the Promise returned by compactDrafts() to resolve before the compacting has started. This is a change in behaviour which could have unwanted side effects. There are multiple calls to await compactDrafts() which assume that any code executed after calling await compactDrafts() is executed after compacting has finished.

This PR suggests keeping the 1s delay to mitigate Bug 1909111, but make the Promise returned by compactDrafts() resolve after the additional delay and after compacting the folder has finished, restoring the original execution flow and keeping the 1s delay to mitigate Thunderbird Bug 1909111.

jikamens commented 3 months ago

The compact is happening asynchronously on purpose. It becomes a user-visible delay if it's done synchronously, and now that I've had to increase it from 1 second to 2 seconds because 1 second apparently isn't enough, that would make it even worse for it to happen synchronously.