Wazarr94 / haxball_bot_headless

Ready-to-go scripts and functions for the HaxBall Headless API !
MIT License
46 stars 74 forks source link

corrupt recording files occasionally #36

Closed iwishiknewcoding closed 2 years ago

iwishiknewcoding commented 2 years ago

On some occasions, roughly once every 3-4 recordings (sometimes even two or three consecutive ones), the file sent to discord is corrupt (9 bytes), I have tried to find the root cause but couldn't find anything that might be causing this. There's no errors in the console whatsoever.

Do you have any ideas? Thanks

image
Wazarr94 commented 2 years ago

Sorry, have never seen this issue on a server with dozens of game a day. Could you send the bugged replay here? You'll need to compress it in a zip file to send it.

If people also encounter this problem, let me know.

Also, I've just seen that days and minutes have missing 0's, will fix this

iwishiknewcoding commented 2 years ago

The content of the bugged replay is just text saying undefined. I think I found a solution though, haven't had the room running for long enough after the fix to be 100% sure if the bugged replays are not sent again, but it's already been ~20 recordings that are fine. Here's what I did:

Change this:

        if (fetchRecordingVariable) {
            setTimeout(() => { fetchRecording(game); }, 1000);
        }

To this:

        if (saveRecordingVariable) {
            setTimeout((gameParam) => { saveRecording(gameParam); }, 1000, game);
        }

Quick note though, I've had the setTimeout set to 1 second, because with 0.5s sometimes the recording would get sent before the match report itself, and that was not looking good. Could that be the issue of the recording file content sometimes being undefined?

Wazarr94 commented 2 years ago

Glad to see you found and fixed the problem. Once again, I will post your solution, I was thinking about doing that as well. FYI I'm doing the CS stat implementation, I'll post this fix with the GK update.

Wazarr94 commented 2 years ago

pushed fix