I think I found the issue. Searched the logs for your user ID and found memory errors for the last few days (prior, you had the duplicate issue).
The problem appears to be that for every game in the favorites list, Laravel is loading every user who favorited that game and every user who is restricted from it. If just one popular game has 1,000+ favorites, that’s 1,000+ User models in memory. So, when it exceeds memory, it’s crashing.
I’m trying to get the code fixed right now. May take a couple of tries before I get it. Like I’ve said before, I’m not a dev. But I’m fairly good at muddling my way through code to make it do what I want… eventually.
I’ll post up here when I’m ready for you to try it again. If anyone sees issues with their favorites today, please be patient. I want to get it fixed, but may break things in the process.
Not sure why it was done this way. I didn’t like that you could duplicate favorites, either (there were thousands of these in the db). I had never paid attention to the structure before I found that problem, but have fixed it in the db by adding a unique key on user.id + game.id.
For this? I’m not sure. I’m trying to pick through the code with chatgpt’s help, but keep having to correct it on how the code is structured and why it is that way (it was trying to remove chunks of code that break the whole program).
The offending function appears to be this:
public function favorites(): View
{
$user = Auth::user();
$games = Game::with(['usersWithFavorite', 'usersRestrictedAccess'])
->whereRelation('usersWithFavorite', 'user_id', '=', $user->id)
->where(function (Builder $query) use ($user) {
$query->doesntHave('usersRestrictedAccess')
->orWhereHas('usersRestrictedAccess', function (Builder $query) use ($user) {
$query->where('user_game_restricted_access.user_id', '=', $user->id)
->orWhere('game.user_id', '=', $user->id);
});
})
->orderBy('title', 'asc') // Sorting by the 'title' column in ascending order
->paginate(10);
return view('games.favorites', compact('games', 'user'));
}
Huh. I’d have guessed from the look of it that it would just build a SQL query, and a database server that can’t handle large database tables isn’t a very good database server…
It’s not really SQL having the issue, it’s PHP getting stuck in a loop and throwing PHP memory errors. I mean, I could bump up the memory allocated for it, but I think the problem will just happen again unless I fix the root cause. From the laravel logs…
[2025-07-06 07:15:13] local.ERROR: Allowed memory size of 31457280 bytes exhausted (tried to allocate 20480 bytes) {“userId”:xxxx,“exception”:"[object] (Symfony\Component\ErrorHandler\Error\FatalError(code: 0): Allowed memory size of 31457280 bytes exhausted (tried to allocate 20480 bytes) at /var/www/cogdemos/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:2299)
@Big_fan1231 When you get a chance, try your favorites again. I made a small change to the function that might fix the problem. I still haven’t been able to duplicate it on my end, but I found a user with 402 favorites, so I am going to copy that to one of my test logins and see what happens.
Yeah, so obviously that function does something else than what I’d have guessed, because if it did what I guessed then PHP would have no reason to choke.
Well, I copied all of the favorites from the user who had 402 games favorited (@MattisHell333, I’m assuming you got a 500 error on your favorites??) and could access them with no issues. They are paginated (40 pages worth). I clicked through them and had no issues.
Hopefully, this fixed everyone’s 500 error for their favorites. I’ll wait to hear back from people. If it works, I’ll push this change up.
hi anyone has a problem for save game ? me i can’t. its said storage full, delete olders saves or free up before try again. i 've also this problem with many games. it’s the first time i 've this problem. thanks for your help !
Is this for local saves? Are you on a mobile device?
Unfortunately, it looks like I’m going to need to alter the code to limit the number of local saves people can have per game, similar to how server-side saves are done. It will mean people will need to export their saves more often, but it should solve this storage error people are getting. I’ve never seen it on my end, but I tend to play on my laptop, rather than on a mobile device (mainly because the print is too small for me and, if I make it large enough, there are like three words before I have to scroll, lol).
I think even if we use indexedDB, we’d end up with this issue on mobile. The saves aren’t very large, but I think some devices are having issues. Not sure if I can make the limit device-based or not. Going to tinker with it and, if I hit a dead end, I’ll get the dev to deal with it.
I’m not sure about Android, but iOS has a fixed amount of storage space allocated to browser cache files (although in my experience, it just frees up space by deleting the old ones), while on a computer you can change it, so yeah, you wouldn’t see it on a computer unless you have a limit and are running low on space.
Is there a way to change the email I signed up with without logging in? I used the wrong email on signup. The email address isn’t mine, but I often forget/make this mistake because it was my first choice for an email address to use and I only added numbers to mine so it’s different. I am being taken to the verification page and I can’t verify since I don’t own the email. I already uploaded a demo so I can’t just open another account. Thanks!
Sure, just DM me what email address you’d like it changed to, along with your username on COGDemos. I can change it, then let you know when it’s done.
Anyone who wants their email address changed can just shoot me a message–I’m trying to get all the email verification done before pulling the new code in prod.
As an aside, I’ve decided to pull the Patreon code into prod–it may not be working perfectly yet, but the dev feels we may be better able to troubleshoot issues with more people using it. Plus, he wants to get the saves fixed and is basing that on the updated code–we don’t want to get too far ahead of prod or we may have problems when I pull it.
Hey, so I logged into both my Moody and CoG Demos accounts this morning and started getting two error messages. At first, I didn’t think much of it — I just assumed the server was being worked on or maybe it was temporarily down. But now it’s around 4:54 where I am, and I’m still getting the same errors.
What is your user name and the email address associated with it?
And neither site is working for you? I haven’t made in changes to either site in several weeks, so I’m not sure why it would be throwing these errors. I can take a look at your account and see if there’s a problem on that side.
Hello! I’m having trouble exporting my save. Which is weird because a few days ago I already exported one save from that same WIP and I didn’t experience any problems with it. The save file would only have 7 slots used so it’s not a matter of having too many slots occupied, but I don’t know what the actual problem would be. I’m guessing it’s a bug. Is someone having the same issue? It keeps telling me “Failed to export saves”.