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

[Fix/Refactor] Make all logs async #3507

Merged
merged 6 commits into from
Feb 4, 2024
Merged

[Fix/Refactor] Make all logs async #3507

merged 6 commits into from
Feb 4, 2024

Conversation

arielj
Copy link
Collaborator

@arielj arielj commented Feb 3, 2024

This PR is a continuation of #3384.

In that PR I moved the lastPlay logs to be async, and this PR moves the rest of the logs to behave the same.

This has 2 main benefits:

  • we write logs in batch every 1 second when there are enqueued message instead of writing once for every message (avoid writes when they happen too quickly which is an expensive operation)
  • if, for any reason, writing to a log fails, the main action that is logging something is not impacted and can continue normally ( should fix Games don't launch a second time #3289 for example)

I included one fix: there was an error in the logs when stopping a sideloaded app


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 Feb 3, 2024
@arielj arielj requested review from a team, flavioislima, CommandMC, Etaash-mathamsetty, Nocccer and imLinguin and removed request for a team February 3, 2024 02:45
{ prefix: 'Backend', skipLogToFile: true }
)
})
// FIXME: this test for some reason is correct in CI but `app.getPath` returning 'invalid'
Copy link
Member

Choose a reason for hiding this comment

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

Maybe run it if the ENV for CI is true.
Something like:
if (process.env.GITHUB_ACTIONS) {

Copy link
Collaborator Author

@arielj arielj Feb 4, 2024

Choose a reason for hiding this comment

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

one thing I'm seeing now is that this is testing a case that will never happen

because from the getPath method docs, when it returns a string it's a valid path and when it's invalid it throws an error (that we are not catching), it should never return an invalid path https://www.electronjs.org/docs/latest/api/app#appgetpathname

we seem to be handling an invalid path incorrectly

I'd rather remove this test to avoid a false sense of correctness, we should actually do a try/catch in createNewLogFileAndClearOldOnes and return if the path is invalid

Copy link
Collaborator Author

@arielj arielj Feb 4, 2024

Choose a reason for hiding this comment

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

I updated the function to try/catch and re-implemented the test to reflect the Error thrown.

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.

LGTM

@flavioislima flavioislima modified the milestone: 2.13.0 Feb 4, 2024
@arielj arielj merged commit 67a351d into main Feb 4, 2024
9 checks passed
@arielj arielj deleted the async-logs branch February 4, 2024 18:30
@Heroic-Games-Launcher Heroic-Games-Launcher locked and limited conversation to collaborators Feb 4, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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.

Games don't launch a second time
2 participants