Skip to content

Bug 41114: Fix no-async-promise-executor on TorConnect and general refactor

Merge Info

Related Issues

Backporting

Timeline

  • Immediate: patchset needed as soon as possible
  • Next Minor Stable Release: patchset that needs to be verified in nightly before backport
  • Eventually: patchset that needs to be verified in alpha before backport
  • No Backport (preferred): patchset for the next major stable

(Optional) Justification

  • Emergency security update: patchset fixes CVEs, 0-days, etc
  • Censorship event: patchset enables censorship circumvention
  • Critical bug-fix: patchset fixes a bug in core-functionality
  • Consistency: patchset which would make development easier if it were in both the alpha and release branches; developer tools, build system changes, etc
  • Sponsor required: patchset required for sponsor
  • Localization: typos and other localization changes that should be also in the release branch
  • Other: please explain

Merging

  • Merge to tor-browser - !fixups to tor-browser-specific commits, new features, security backports
  • Merge to base-browser - !fixups to base-browser-specific commits, new features to be shared with mullvad-browser, and security backports
    • NOTE: if your changeset includes patches to both base-browser and tor-browser please clearly label in the change description which commits should be cherry-picked to base-browser after merging

Issue Tracking

Review

Request Reviewer

  • Request review from an applications developer depending on modified system:
    • NOTE: if the MR modifies multiple areas, please /cc all the relevant reviewers (since gitlab only allows 1 reviewer)
    • accessibility : henry
    • android : clairehurst, dan
    • build system : boklm
    • extensions : ma1
    • firefox internals (XUL/JS/XPCOM) : ma1
    • fonts : pierov
    • frontend (implementation) : henry
    • frontend (review) : donuts, richard
    • localization : henry, pierov
    • macos : clairehurst, dan
    • nightly builds : boklm
    • rebases/release-prep : dan, ma1, pierov, richard
    • security : ma1
    • signing : boklm, richard
    • updater : pierov
    • misc/other : pierov, richard

Change Description

TorConnect used to have many async promise executor, which are a problem because under some cirumstances the exceptions might be lost.

After starting to remove the async executors, I noticed they were not really needed, since for most of the time they were used only to make sure we blocked the transition to the next state until actually needed. Also, the promised were resolved in a cleanup function created only for this purpose in most of all occurrences. In many cases, the state callback does not even need to be async. So, I thought I could shift the waiting from the function that started the state callback to the function that actually performs the state change.

Also, to simplify the code (at least remove a lot of indentation levels), I switched the states from being functions to actual ES classes. We used to create a companion object (this._context) in any case, and for this reason we had to use the function keyword instead of arrow functions. Therefore, I thought of replacing it with explicitly being OOP.

For the reviewer(s): please go through every commit! The general review will basically be the whole file rewritten. The second, third and last commit, in particular, are trivial to review only if you do something special:

  • for the second commit, you should use git show --color-moved. It will show the actual changes are just a few
  • for the third commit, you can just lint the file from the second commit locally before switching to the third commit, and then check that you get the same result (no need to check if the linter works, right? 🙂 )
  • for the last commit, remove the surrounding function and then lint, you should get the same result as my commit.

How Tested

I went commit by commit and tested that:

  • with censorship level set to 1 we manage to bootstrap
  • we don't get any strange error messages in the console
  • canceling the bootstrap produces immediate results

Merge request reports

Loading