HGL
Heroic Games Launcherโ€ข3y ago
rare-sapphire

Legendary Deletes User.json

See the attached images. After starting Heroic, the legendary user.json deleted itself even though I have a valid refresh-token. Heroic complains that I am logged out. Bug in Legendary or in Heroic launcher?
No description
No description
39 Replies
rare-sapphire
rare-sapphireOPโ€ข3y ago
This has happened 2 days in a row. I've been using Heroic since 2 days ago.
CommandMC
CommandMCโ€ข3y ago
This is not "our" bug. Epic is reporting that your refresh token is invalid even though it should still be valid (according to the time given) For more info, see #Heroic needs a re-login too often, specifically https://discord.com/channels/812703221789097985/1079344811733159976/1081921026331508786
adverse-sapphire
adverse-sapphireโ€ข3y ago
are you able to consistently reproduce this problem? this is not happening for any of the main developers of the project so we don't know if we can have at least some workaround, would be great if you have consistent steps to at least reproduce it on your end
rare-sapphire
rare-sapphireโ€ข3y ago
what if epic games made everyone other than the developers get the issue so that people stop using heroic /s
rare-sapphire
rare-sapphireOPโ€ข3y ago
Yeah I started really using Heroic 2 days ago, it's a 1 month old install where I had been using GOG, without any Epic login ever in my ~/.var/app data for Heroic. 2 days ago, I logged into Epic and installed Death Stranding. Then closed Heroic. Came back to open Heroic like 10 hours later, and was logged out. So I logged back in, made a note of the info in that file (my screenshot above was that file version). Closed Heroic. Waited 12 hours or so, and then started Heroic again. Was logged out again. I am not using any VPN so it couldn't be a "log out due to IP switching" either. :S
adverse-sapphire
adverse-sapphireโ€ข3y ago
if that happens again, can you check the legendary log? go to settings > logs > show log file in folder > look for the last legendary....log I want to see if there's any error in the output saying the credentials were wrong or what
adverse-sapphire
adverse-sapphireโ€ข3y ago
I just had a login issue, this is my log, I don't know if it's the same that other people are having (it failed to connect to the epic servers)
adverse-sapphire
adverse-sapphireโ€ข3y ago
oh wait, no, nevermind, I had that issue, but I did not get logged out :S
rare-sapphire
rare-sapphireOPโ€ข3y ago
First time that I got logged out:
[2023-03-26 23:55:21] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary --version
legendary version "0.20.32", codename "Dark Energy (hotfix #6)"
[2023-03-26 23:55:22] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary list --third-party
[cli] INFO: Logging in...
[2023-03-26 23:55:23] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary list --third-party
[cli] INFO: Logging in...
[Core] INFO: Logging in...
[cli] INFO: Getting game list... (this may take a while)
[Core] INFO: Logging in...
[EPCAPI] ERROR: Login to EGS API failed with errorCode: errors.com.epicgames.account.auth_token.invalid_refresh_token
[Core] ERROR: Stored credentials are no longer valid! Please login again.
[cli] ERROR: Login failed, cannot continue!
[2023-03-26 23:55:21] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary --version
legendary version "0.20.32", codename "Dark Energy (hotfix #6)"
[2023-03-26 23:55:22] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary list --third-party
[cli] INFO: Logging in...
[2023-03-26 23:55:23] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary list --third-party
[cli] INFO: Logging in...
[Core] INFO: Logging in...
[cli] INFO: Getting game list... (this may take a while)
[Core] INFO: Logging in...
[EPCAPI] ERROR: Login to EGS API failed with errorCode: errors.com.epicgames.account.auth_token.invalid_refresh_token
[Core] ERROR: Stored credentials are no longer valid! Please login again.
[cli] ERROR: Login failed, cannot continue!
I then logged in again. Here's a working re-use while the new token was valid:
[2023-03-27 00:17:46] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary --version
legendary version "0.20.32", codename "Dark Energy (hotfix #6)"
[2023-03-27 00:17:47] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary list --third-party
[cli] INFO: Logging in...
[Core] INFO: Trying to re-use existing login session...
[cli] INFO: Getting game list... (this may take a while)
[2023-03-27 00:17:47] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary list --third-party
[cli] INFO: Logging in...
[Core] INFO: Trying to re-use existing login session...
[cli] INFO: Getting game list... (this may take a while)
[2023-03-27 00:17:46] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary --version
legendary version "0.20.32", codename "Dark Energy (hotfix #6)"
[2023-03-27 00:17:47] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary list --third-party
[cli] INFO: Logging in...
[Core] INFO: Trying to re-use existing login session...
[cli] INFO: Getting game list... (this may take a while)
[2023-03-27 00:17:47] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary list --third-party
[cli] INFO: Logging in...
[Core] INFO: Trying to re-use existing login session...
[cli] INFO: Getting game list... (this may take a while)
And then 12 hours later I was logged out again when the new token was also invalid:
[2023-03-27 16:09:35] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary --version
legendary version "0.20.32", codename "Dark Energy (hotfix #6)"
[2023-03-27 16:09:37] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary list --third-party
[2023-03-27 16:09:37] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary list --third-party
[cli] INFO: Logging in...
[Core] INFO: Logging in...
[cli] INFO: Logging in...
[Core] INFO: Logging in...
[cli] INFO: Getting game list... (this may take a while)
[EPCAPI] ERROR: Login to EGS API failed with errorCode: errors.com.epicgames.account.auth_token.invalid_refresh_token
[Core] ERROR: Stored credentials are no longer valid! Please login again.
[cli] ERROR: Login failed, cannot continue!
[2023-03-27 16:09:35] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary --version
legendary version "0.20.32", codename "Dark Energy (hotfix #6)"
[2023-03-27 16:09:37] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary list --third-party
[2023-03-27 16:09:37] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary list --third-party
[cli] INFO: Logging in...
[Core] INFO: Logging in...
[cli] INFO: Logging in...
[Core] INFO: Logging in...
[cli] INFO: Getting game list... (this may take a while)
[EPCAPI] ERROR: Login to EGS API failed with errorCode: errors.com.epicgames.account.auth_token.invalid_refresh_token
[Core] ERROR: Stored credentials are no longer valid! Please login again.
[cli] ERROR: Login failed, cannot continue!
I did a grep in all logs, I do not have a connection error. So that's not it for me at least. Have you tried the sequence of events that I do? 1. Login to Epic via MAIN login method (not the alternative method). 2. Restart the computer 3. Do not start Heroic at all 4. Wait until the "expires_at" in user.json has expired 5. Now start Heroic. That is 100% at getting me logged out so far. 2 of 2 times. As soon as the token has expired I am logged out. If Heroic client stays open in the background or if you play any of the Epic games, your token may constantly be refreshed behind your back. Try letting it expire. PS: I decided to use the alternative login method now for my 3rd try. Perhaps that stays logged in better since it piggybacks a website token. The alternative login method generated this user.json now:
"expires_at": "2023-03-28T11:48:45.115Z",
"expires_in": 28800,
"internal_client": true,
"refresh_expires": 1987200,
"refresh_expires_at": "2023-04-20T03:48:45.116Z",
"expires_at": "2023-03-28T11:48:45.115Z",
"expires_in": 28800,
"internal_client": true,
"refresh_expires": 1987200,
"refresh_expires_at": "2023-04-20T03:48:45.116Z",
Will be interesting to see if this stays alive.
rare-sapphire
rare-sapphireโ€ข3y ago
I think we should find a way to make the alternative login more robust So you don't have to copy and paste anything Then make it the default
CommandMC
CommandMCโ€ข3y ago
[EPCAPI] ERROR: Login to EGS API failed with errorCode: errors.com.epicgames.account.auth_token.invalid_refresh_token
[EPCAPI] ERROR: Login to EGS API failed with errorCode: errors.com.epicgames.account.auth_token.invalid_refresh_token
and there it is again: Epic is saying your refresh token is invalid even if it shouldn't be Alternative login is not much different to the normal login method, the only difference is that you have to copy-paste the auth code yourself (while in normal login, Heroic will read it out by itself). Other than that, the same website is opened, the same command is ran
adverse-sapphire
adverse-sapphireโ€ข3y ago
yes, the main login method is literally the alternative login method automated, it points to the same url, but it does that inside heroic so we can wait and automatically copy/paste the auth token for the same legendary command @Arcitec what I see from your log is something another user reported, there are 2 calls to /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary list --third-party right next to each other in the logs when the login fails, but there's some extra logs between those 2 calls when the login does not fail can you try with the build from the main branch from github and see if the error still happens? if it does I will try some workaround to reuse the current call to that command instead of doing 2 in parallel (legendary is not meant to run more than once at a time)
rare-sapphire
rare-sapphireOPโ€ข3y ago
That sounds like a plausible explanation. I have a few questions about how best to test this: 1. I currently have an expired Alternate Login (first time I use that method) which I was gonna test. That token is expired. Should I open my currently installed client just to see if that works better at refreshing? Or should I switch to the newest main build and see if that one survives? 2. If I switch build, is there some place I can download the latest main nightly as a flatpak file? I think you are right about the error being the sequence of Legendary calls btw. I totally see it. Two "list games - third party" commands are started in parallel and both of them immediately realize that Epic is logged out and both are attempting to renew the token simultaneously and both attempt to overwrite user.json simultaneously. This needs fixing for sure. Since I have a currently expired token, and since it takes so long to wait for an expiry (half a day), we should maximize the impact of the next test. Any chance of a test build where the "list games" commands are reprogrammed to run in series instead of parallel? It's also weird why two of the same "list games - third party" are being run at startup. One would be enough, surely?
adverse-sapphire
adverse-sapphireโ€ข3y ago
GitHub
[Feature] Pause/resume downloads (#2551) ยท Heroic-Games-Launcher/He...
A Native GOG and Epic Games Launcher for Linux, Windows and Mac. - [Feature] Pause/resume downloads (#2551) ยท Heroic-Games-Launcher/HeroicGamesLauncher@304fd12
adverse-sapphire
adverse-sapphireโ€ข3y ago
yes, we have an issue that heroic does a library refresh at boot to make sure the list is up to date, but then the frontend also asks for a refresh to check for game updates, I think those 2 things sometimes happen too close to each other what I'll try later is to make it so, if we ask for the list to legendary and there's already a command running for the same thing, to reuse the same promise instead of starting a new one if that doesn't work I'll just try delaying the check for updates by like 10 seconds or so I won't have time until later tonight to do any change so I think it's fine to test with the latest main build, the new build with the calls change will be probably ready for tomorrow
rare-sapphire
rare-sapphireOPโ€ข3y ago
Yeah I am pretty sure you've found the issue. The logs even seem to indicate it: The 1st call to list-games successfully refreshed the token. The 2nd parallel call gets a server reply that the token is invalid, because the "refresh my old token plz" command is referring to a token that the server literally already renewed and deleted half a second ago, so the 2nd refresh-command gets the "it's invalid" response. Thus the 2nd command "wins" at deleting the user.json file and saying that we've been logged out. Your idea of making a queue is something I was considering too: Would it be possible to make a Legendary Command Queue class for general usage? Which takes as input a list of promises and runs the Legendary command promises 1 by 1, instead of all at once? That would avoid any and all future race conditions. Anyway, since it will take time to work on that, I'll try the latest main in a moment.
adverse-sapphire
adverse-sapphireโ€ข3y ago
the weird this is that I literally tried this legendary list & legendary list to run the command twice as soon as possible on the terminal but I didn't have issues, but maybe my token was not expired? I'll try that later too
CommandMC
CommandMCโ€ข3y ago
I assume this is why only some people have these issues https://www.npmjs.com/package/async-mutex sounds like an easy way to solve this
npm
async-mutex
A mutex for guarding async workflows. Latest version: 0.4.0, last published: 7 months ago. Start using async-mutex in your project by running npm i async-mutex. There are 581 other projects in the npm registry using async-mutex.
CommandMC
CommandMCโ€ข3y ago
Yup that seems to work, uploading that to a branch now to test (This will of course lead to other issues, like not being able to check for updates while a game is installing; but at least we know about those)
rare-sapphire
rare-sapphireOPโ€ข3y ago
So here's what was created last night (when I used Alternative Login instead):
"expires_at": "2023-03-28T11:48:45.115Z",
"expires_in": 28800,
"internal_client": true,
"refresh_expires": 1987200,
"refresh_expires_at": "2023-04-20T03:48:45.116Z",
"expires_at": "2023-03-28T11:48:45.115Z",
"expires_in": 28800,
"internal_client": true,
"refresh_expires": 1987200,
"refresh_expires_at": "2023-04-20T03:48:45.116Z",
Here's the log today when refreshing it via the latest "main" build that you gave me above.
[2023-03-28 17:32:59] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary --version
legendary version "0.20.32", codename "Dark Energy (hotfix #6)"
[2023-03-28 17:33:00] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary cleanup
[cli] INFO: Cleanup complete! Removed 0.01 MiB.
[2023-03-28 17:33:00] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary list --third-party
[cli] INFO: Logging in...
[Core] INFO: Logging in...
[cli] INFO: Getting game list... (this may take a while)
[2023-03-28 17:33:01] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary list --third-party
[Core] INFO: Fetching metadata for 1 app(s).
[cli] INFO: Logging in...
[Core] INFO: Trying to re-use existing login session...
[cli] INFO: Getting game list... (this may take a while)
[Core] INFO: Fetching metadata for 1 app(s).
[2023-03-28 17:32:59] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary --version
legendary version "0.20.32", codename "Dark Energy (hotfix #6)"
[2023-03-28 17:33:00] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary cleanup
[cli] INFO: Cleanup complete! Removed 0.01 MiB.
[2023-03-28 17:33:00] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary list --third-party
[cli] INFO: Logging in...
[Core] INFO: Logging in...
[cli] INFO: Getting game list... (this may take a while)
[2023-03-28 17:33:01] /app/bin/heroic/resources/app.asar.unpacked/build/bin/linux/legendary list --third-party
[Core] INFO: Fetching metadata for 1 app(s).
[cli] INFO: Logging in...
[Core] INFO: Trying to re-use existing login session...
[cli] INFO: Getting game list... (this may take a while)
[Core] INFO: Fetching metadata for 1 app(s).
And the new user.json:
"expires_at": "2023-03-28T23:33:01.163Z",
"expires_in": 28800,
"internal_client": true,
"refresh_expires": 1987200,
"refresh_expires_at": "2023-04-20T15:33:01.164Z",
"expires_at": "2023-03-28T23:33:01.163Z",
"expires_in": 28800,
"internal_client": true,
"refresh_expires": 1987200,
"refresh_expires_at": "2023-04-20T15:33:01.164Z",
So yes they ran sequentially this time and the token refresh worked. I hope this was a result of a previous change to main to try to make this sequential? Due to the other person having brought this up too? If you can make this even more robust though, to ensure it's always serial, that would be great! ๐Ÿ™‚
CommandMC
CommandMCโ€ข3y ago
https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/pull/2580 Got that opened up now. As noted in the description, this will have a lot of issues, but will definitely resolve this logging-out issue (provided it is caused by the two commands running at the same time, which seems likely) (Oh meant to reply to this)
rare-sapphire
rare-sapphireOPโ€ข3y ago
That looks like a perfect solution to ensure legendary commands never run in parallel.
CommandMC
CommandMCโ€ข3y ago
Well, we want them to in a few cases. The most important one I'd say is downloading a game while doing anything else. That's where this solution somewhat falls flat
rare-sapphire
rare-sapphireOPโ€ข3y ago
Yeah it's more important that users stay logged in. The install scenario can be improved later by making the install command release the mutex after 10 seconds. @CommandMC imLinguin has a superb idea in the pull request. ๐Ÿ™‚ Check out his comment.
adverse-sapphire
adverse-sapphireโ€ข3y ago
Derrod said he plans to add a lock mechanism in legendary to prevent running it twice the thing is this will prevent enqueuing epic games while an epic game is being installed for example
adverse-sapphire
adverse-sapphireโ€ข3y ago
GitHub
Uninstalling a game while another game is being installed is "rever...
Platform Operating system and version: Linux Mint 21 Legendary version (legendary -V): 0.20.32 Dark Energy (hotfix #6) Expected Behavior If I uninstall a game while another game is installing, I ex...
rare-sapphire
rare-sapphireOPโ€ข3y ago
Hmm. That's the wrong solution. All legendary needs is granular locking of the library and user json files. If locked: Wait until lock is free, read the latest file contents and proceed.
adverse-sapphire
adverse-sapphireโ€ข3y ago
yeah, sounds too extreme to me
rare-sapphire
rare-sapphireOPโ€ข3y ago
Yeah that heavy locking of the entire process would break parallel downloads and would break launching games while waiting for downloads. A lock is pretty simple. And just doing that before the "load/write user.json" and "load/write library.json" steps.
adverse-sapphire
adverse-sapphireโ€ข3y ago
hey @Arcitec can you try using the build from this PR https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/pull/2585 ? and see if you still have the issue? now during startup it will only do one call to legendary list so I hope that fixes the problem without needing the lock
GitHub
Call legendary list only once when refreshing the library by arie...
This might fix the login issues that seems to be caused by 2 calls to legendary list happening at the same time. We were doing 2 calls: one to refresh the library and, if checking updated, one to p...
rare-sapphire
rare-sapphireOPโ€ข3y ago
Thank you, great work! That looks brilliant and will definitely solve Heroic's logouts until Legendary has locking itself. There could be some rare race condition where two commands still get started by Heroic in some other place, but it won't be happening at every login anymore. So this will make Heroic usable and allows Legendary to calm down with implementing the locking, since derrod is busy. I would download the new build as flatpak but they aren't being built by the way, red โŒ https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/commits/main
GitHub
Commits ยท Heroic-Games-Launcher/HeroicGamesLauncher
A Native GOG and Epic Games Launcher for Linux, Windows and Mac. - Commits ยท Heroic-Games-Launcher/HeroicGamesLauncher
rare-sapphire
rare-sapphireOPโ€ข3y ago
I have an expired session for sure, so I could test it as soon as I have access to a new flatpak build. ๐Ÿ™‚ Just got to my computer and noticed that the only build that fails is for Mac. I'll download the Linux build from the latest main. Edit: Installing https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/actions/runs/4569798721 @arieljuod Tried it out now and it only calls legendary list-games once at startup, and Legendary refreshed session without issue. Excellent work. ๐Ÿ™‚ Hope it can be pushed as a release to flathub asap, so I can switch over my family computers back to flathub auto-updates.
rare-sapphire
rare-sapphireโ€ข3y ago
we finally fixed it, nice
xenial-black
xenial-blackโ€ข3y ago
Don't know what you mean by flatpak build different but here is the flaptak binary for this pr: https://github.com/Heroic-Games-Launcher/HeroicGamesLauncher/suites/11930375672/artifacts/625041481
foreign-sapphire
foreign-sapphireโ€ข3y ago
When will this fix be in the official version?
xenial-black
xenial-blackโ€ข3y ago
Next release. Will come probably next week
foreign-sapphire
foreign-sapphireโ€ข3y ago
:OKAY:
rare-sapphire
rare-sapphireโ€ข3y ago
Maybe with DXVK-NVAPI integration too ๐Ÿ‘€
CommandMC
CommandMCโ€ข3y ago
@Arcitec @basti With the latest Heroic release, this issue should now be gone Tagging this as "Solved" & closing, feel free to reopen if the issues persist

Did you find this page helpful?