Skip to content

Investigate potential race condition in UnitDisplay.tick() buildables updates #3334

@coderabbitai

Description

@coderabbitai

Description

In src/client/graphics/layers/UnitDisplay.ts, the tick() method calls player.buildables(undefined, BuildMenus.types) without guarding against overlapping requests or handling promise rejections.

Potential Issues

  1. Race condition: If tick() is called multiple times before the first promise resolves, older responses may overwrite newer state in this.playerBuildables.
  2. Unhandled rejections: Missing .catch() handler could allow unhandled promise rejections.

Context

This was flagged during review of PR #3220 but deferred for separate investigation.

Requested by: @VariableVince
PR: #3220
Review comment: #3220 (comment)

Next Steps

Verify whether the race condition can occur in practice and whether error handling is needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions