Skip to content

iOS: single-flight guard is released before the post-download load completes #35

Description

@fonkamloic

From PR #34's round-5 review (raised there as out-of-scope for that PR; filed here so it has its own tracked fix):

The install path returns the iOS load future without awaiting it, so the single-flight guard's finally clears _checkInFlight as soon as the load hits its first suspension — the returned future is chained after the finally runs (the standard "use return await inside a try block" case). Consequences:

  1. A concurrent full check can run while the first load is still in flight — the exact scenario the guard's own rationale says it exists to prevent (a second load of the same payload throws on iOS, and its rollback would revert the copy the first call just loaded successfully).
  2. The load path's terminal status writes are only best-effort ordered (now documented as such in the dartdoc/README qualifier added in PR Clear deferred-medium backlog: single-flight status write + example mounted guards #34).

Fix shape: return await at the install-path return so the guard is held across the load. This changes when the guard releases, so it deserves its own PR with tests covering: concurrent check during a slow load (guard held → loser stamps), and the rollback-during-load hazard above.

Review context: #34 (round-5 comment, "Separately, and not a request for this PR").

Metadata

Metadata

Assignees

No one assigned

    Labels

    deferred-mediumMedium finding deferred at merge; fix once the audit backlog clears

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions