Skip to content

Single-player games are intermittently not archived or counted in player profile #4875

Description

@gabrieleciolino

Description

Completed single-player games are intermittently not saved to the player's profile. When the issue occurs, the game does not appear in recent games, its statistics are missing, and even the number of games played in the server-side profile is not incremented.

The relevant request appears to be:

POST /archive_singleplayer_game

The problem was initially noticed while an ad blocker was enabled. However, repeating the same test with the ad blocker still enabled successfully archived a subsequent game, so ad-block detection itself does not appear to be a deterministic cause.

Steps to reproduce

  1. Sign in to an OpenFront account.
  2. Start and complete a single-player game.
  3. Return to the home page or leave the end-game screen.
  4. Open the player profile and check recent games/statistics.
  5. Repeat several times.

Actual behavior

Intermittently:

  • archive_singleplayer_game does not successfully persist the game;
  • the completed match is absent from the profile;
  • match statistics are absent;
  • the profile does not reflect that the game was played.

Other games under the same browser/ad-block configuration are saved correctly.

Expected behavior

Every completed single-player game should be archived exactly once and reflected in the authenticated player's profile, even if the player navigates away shortly after the match ends.

Possible implementation issue

In src/client/LocalServer.ts, endGame() invokes the async archive operation without awaiting it:

this.archiveGame(result.data);

Before the fetch starts, archiveGame() still needs to:

  1. retrieve the authorization header;
  2. serialize the game record;
  3. gzip-compress the payload.

Although the eventual request uses keepalive: true, navigation or page teardown may happen before the fetch is created. This could make the failure timing-dependent.

Additionally, the response status is currently not checked:

await fetch(`${getApiBase()}/archive_singleplayer_game`, ...);

A resolved HTTP response such as 401, 403, 413, 429, or 5xx would therefore not enter the catch block and would not produce a visible archive error.

Suggested improvements

  • Ensure the archive operation is awaited or otherwise reliably queued before navigation/page teardown.
  • Check response.ok and log the response status/body on failure.
  • Consider retrying transient failures or persisting an unsent archive locally for later retry.
  • Show a visible saving/saved/failed state on the end-game screen.

Environment

  • Web version: https://openfront.io/
  • Authenticated player profile
  • Single-player mode
  • Browser extension/ad blocker enabled during the initial failures, but the issue did not reproduce on every attempt with the same configuration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    not-approvedThis issue has NOT been approved by the maintainers.

    Type

    No type

    Projects

    Status
    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions