Skip to content

fix(storage): one hung secure-storage call now blocks every later token operation, including each request's token read and logout's clear #1002

Closed

Description

@koniz-dev

Found by the pre-merge review of #1001 (for #986). Confirmed from the code on that branch.

Summary

SecureTokenStore now runs every token read, write and delete in issue order, so that a logout's clear lands after a pending refresh write (#986). The flip side: a platform call that never completes (a flutter_secure_storage read, write or delete that hangs, as opposed to one that fails) now holds every later token operation behind it. That includes AuthInterceptor.onRequest's token read on every request, and a logout's clearAllTokens(). The app then can neither make an authenticated request nor sign out until it is restarted. Before the queue, a hung call stalled only its own caller. Neither SecureStorageService nor the queue has a timeout. A plain timeout inside the queue would let the abandoned call land late and break the ordering again, so this needs a design, not a one-line fix.

Acceptance criteria

  1. A test with a storage whose write never completes shows the chosen behaviour. For example: later operations fail with a CacheException after a bounded wait, and a logout still ends with the session torn down in memory and a retry of the clear scheduled, or another documented outcome that leaves the app usable.
  2. The ordering guarantee tested in secure_token_store_order_test.dart still holds.
  3. The SecureTokenStore class doc describes the bound.

Activity

  1. added
    type:bugSomething that is broken relative to documented behavior
    epic:core-storagelib/core/storage: key-value + secure adapters, token store, migrations
    priority:P2Normal queue: real but not blocking
    status:todoTriaged and startable: has acceptance criteria, nobody assigned
    status:in-progressClaimed by an assignee and being worked right now
    and removed
    status:todoTriaged and startable: has acceptance criteria, nobody assigned
    on Oct 30, 2026
  2. self-assigned this
    on Oct 31, 2026
  3. koniz-dev commented on Oct 31, 2026

    @koniz-dev
    OwnerAuthor

    Fixed by #1021 (squash f01e91d). SecureTokenStore waits for the operation ahead of it at most operationTimeout (10 s by default), then runs anyway.

    Criterion Result Artifact
    1. With a write that never completes, later operations get a documented, usable outcome PASS named-tests.log: a write that never completes stops holding the read and the clear behind it after the bound: the read and the logout clear both run after the bound. mutant-unbounded.log: times out on the unbounded queue
    2. The ordering in secure_token_store_order_test.dart still holds PASS Same log: the three order tests and operations that complete in time keep their order pass
    3. The class doc describes the bound PASS doc-bound.txt

    G2 on main 99d457a (which contains every fix merged this cycle): audit_template.log exits 0 (3861 tests), and g2-checks.log shows check_epic_coverage and check_deliverable exit 0. PR checks: pr1021-checks.txt. G3 found that a call which outlives the bound and then succeeds lands out of order, re-storing a token after a clear. That is filed as #1024 (P1) and fixed by the repair in #1031, which is not merged yet; this issue's criteria (a hang no longer wedges the store) hold on main regardless. Pre-merge review ran (storage surface). No screenshots were produced or cited (run_acceptance.sh was not used, so there are no standing goldens to account for). Self-QA: each artifact was opened and matches its row.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

epic:core-storagelib/core/storage: key-value + secure adapters, token store, migrationspriority:P2Normal queue: real but not blockingstatus:in-progressClaimed by an assignee and being worked right nowtype:bugSomething that is broken relative to documented behavior

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions