Page 1 of 1

Help needed - dreaded "BGA service error"! [RESOLVED]

Posted: 25 May 2021, 20:41
by robinzig
Although I'm new to BGA development, I'm a reasonably experienced developer and pride myself on not having to ask for help very much. But I'm at a loss here.

I've been trying to make progress with my game tonight, was making changes and refreshing the game I had in progress - all seemed fine. But then when I decided to stop the game that was running and "express start" a new one, I suddenly starting getting the dreaded error:

"Unexpected error: Propagating error from GS 1 (method: createGame): BGA service error"

I have seen this before, and have previously been able to resolve it using the excellent troubleshooting guide. But this time I'm utterly at a loss and wondering if there is perhaps some problem with the BGA server itself?

The thing is, the game was running fine 5 minutes before it started doing this - and the only 2 files I'd changed in that time were the .game.php and the .js. I've tried reverting both to the versions I had at the start of the night - and I still get the same error. While it's true that I'd not previously tried to *start* a game for a few days, nothing else has changed since then that would cause the game to fail to start - just the CSS file, and perhaps the .tpl one.

The troubleshooting section I linked to above is frustratingly vague, although doubtless pinpoints the most common causes (and as I said has helped me in the past). There's definitely nothing wrong with my dbmodel, nor with my states (have pasted both into online syntax checkers, just to be sure!), nor do I call initStat anywhere. (I haven't even started to put stats in and probably won't until it's otherwise complete.) And as I said, there is nothing important that's changed since I was last able to successfully create a game. I'm really at a loss, and desparately hoping someone here might know something else that might cause this.

But as I said, I've reverted the only two files (to my knowledge) that have changed since this last worked, and it still fails. And it's hard for me to see what else might have because the "display differences" in the control panel seems to not be responsive (I just see the svn diff command but no output - which is something else that makes me think that maybe there's a server issue? Again this has worked for me before). I just want to be able to continue development on my game, and it's really frustrating not having a clue why things won't start.

Thanks in advance!

Re: Help needed - dreaded "BGA service error"!

Posted: 25 May 2021, 21:29
by Een
I launched another game and it worked so this is not a general issue.

Due to the way the framework is setup, the full logs of the game setup are unfortunately not available, as we don't have yet the means to separate the logs by developers at this stage. Sorry about that, it means that sometimes, you'll have to request admin assistance when the game doesn't start and it's not clear why: don't hesitate to write to studio@boardgamearena.com when needed.

In this case, I checked, and the error is "Not logged". This issue usually occurs when getCurrentUserId() is called during game creation, since during game creation, the user is not defined yet. Stack trace indicates line 914.

Hope it helps!

Re: Help needed - dreaded "BGA service error"!

Posted: 25 May 2021, 21:34
by robinzig
Een wrote: 25 May 2021, 21:29 I launched another game and it worked so this is not a general issue.

Due to the way the framework is setup, the full logs of the game setup are unfortunately not available, as we don't have yet the means to separate the logs by developers at this stage. Sorry about that, it means that sometimes, you'll have to request admin assistance when the game doesn't start and it's not clear why: don't hesitate to write to studio@boardgamearena.com when needed.

In this case, I checked, and the error is "Not logged". This issue usually occurs when getCurrentUserId() is called during game creation, since during game creation, the user is not defined yet. Stack trace indicates line 914.

Hope it helps!

Thank you very much! Yes, I am calling getCurrentUserId on line 914.

However, that is not during game creation, as I understood it. I clearly understood it wrong, but that is called from one of my "arg" methods, for the "first" game state (#2). Which I'm doing to check that the current player is active so that I can send information to the client about the active player's hand. I didn't realise this would be called "during game creation", but at some point shortly after. At any rate, it explains why this error has only just occurred, because I indeed put that in in the past few days, and while it worked fine while the game was "live", this is the first time I've tried to start a new game since.

So, are the methods "argXXX" really forbidden to call getCurrentUserId? If so, how else do you handle needing to send "private" information to the client side for the active player? [That's obviously aimed at all developers here - not just you! :D ]

EDIT: just checked the troubleshooting guide again and, now I knew what to look for, found:

Fatal error during creation of database ebd_quoridor_389 Not logged
Check that you didn't use $g_user or getCurrentPlayerId() in setupNewGame() function or in an 'args' function of your state

So fair enough, this isn't allowed. Need to come up with some other solution then to sending information about the active player's hand to the client!

Re: Help needed - dreaded "BGA service error"! [RESOLVED - but raises a new question!]

Posted: 25 May 2021, 21:46
by Benoit314
Current player only exists when a client side request is done. It represents the player who initiated the request.
Arg methods are called server side and it sends the data to the client (if a player reloads the page, current player may exist, but don't use it, it will throw errors when the game enters the state).

You could send player hands with your getAllDatas method (current player exists there), send a private notification to the player or use _private in a Arg method. Every option depends when you need to send it.

Re: Help needed - dreaded "BGA service error"! [RESOLVED - but raises a new question!]

Posted: 25 May 2021, 21:51
by robinzig
Thank you. I've just been reading through the docs again and see that I've missed this: it's the "_private" key in the args return that I was missing. I can mark this fully resolved! Embarassed to have missed all this (both the initial error, and the correct way to return private information from an argXXX function), despite having definitely seen these a few times in many many reads through all parts of the docs. My only defence is that there's just so much to take in when you're new! :oops:

Re: Help needed - dreaded "BGA service error"! [RESOLVED]

Posted: 26 May 2021, 08:15
by Een
No worries, it's perfectly ok to ask questions and get help, the developer forum is here for that purpose, and indeed there is a lot to take in! :)