Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Refactor] Refactor abort controllers to simplify creation/deletion #3056

Merged
merged 3 commits into from
Oct 25, 2023

Conversation

arielj
Copy link
Collaborator

@arielj arielj commented Sep 17, 2023

We have this pattern in a lot of places:

import {
  createAbortController,
  deleteAbortController
} from './utils/aborthandler/aborthandler'

...
...

const abortId = 'some-id'
runSomeCommand(
  ...
  createAbortController(abortId)
  {
    ...options
  }
)
deleteAbortController(abortId)

This PR is a refactor of that to only need the abortId when calling the functions and the abort controllers are created/deleted internally. It removes a lot of imports and explicit calls to createAbortController and deleteAbortController.

So now we don't need the imports and we can do

runSomeCommand(
  ...
  {
    abortId: 'some-id',
    ...options
  }

The abortId is also now optional, if we want to run something that we don't need to abort manually we can ignore that option.

We can still abort things when needed since the abort controllers are still being tracked and created with the same ID as before.


Use the following Checklist if you have changed something on the Backend or Frontend:

  • Tested the feature and it's working on a current and clean install.
  • Tested the main App features and they are still working on a current and clean install. (Login, Install, Play, Uninstall, Move games, etc.)
  • Created / Updated Tests (If necessary)
  • Created / Updated documentation (If necessary)

@arielj arielj added the pr:ready-for-review Feature-complete, ready for the grind! :P label Sep 17, 2023
@arielj arielj requested review from a team, flavioislima, CommandMC, Nocccer and imLinguin and removed request for a team September 17, 2023 19:11
@@ -826,6 +829,9 @@ async function callRunner(
return currentPromise
}

const abortId = options?.abortId || appName || Math.random().toString()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if no abortId is passed, it tries to get the appName from the command, else it generates a random id

createAbortController(release.version).signal
)
deleteAbortController(release.version)
const result = await installWineVersion(release, onProgress)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since the abortId is release.version, I'm just reading that inside installWineVersion so no need of a parameter, but it's created the same way as before

Copy link
Member

@flavioislima flavioislima left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codewise looks good. It is just a lot of places to test so it is more likely we find bugs after the next release with this change.
although looking at the code I think everything will be fine.

@arielj
Copy link
Collaborator Author

arielj commented Oct 25, 2023

I'm merging this, I tested a lot of things and if we get this merged we can have more developers testing before a release

I don't want to start getting conflicts

@arielj arielj merged commit f5074b9 into main Oct 25, 2023
13 checks passed
@arielj arielj deleted the refactor-abort-controllers branch October 25, 2023 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:ready-for-review Feature-complete, ready for the grind! :P
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants