Skip to content

Race conditions may occur #57

@baarde

Description

@baarde

Hello,

I've noticed that a few race conditions may occur:

  1. When renewing expired credentials, gAuth is updated before generating a new value for jwt. If two tasks happens concurrently and the first one gets preempted after updating gAuth but before the new jwt has been written, the second task may assume the expired jwt is still valid and reuse it, causing an authorization error.

    • Likelihood: May happen occasionally. A robust application should be able to recover from errors and retry later.
  2. When changing the configuration, existing credentials are not invalidated.

    • Likelihood: Won't happen when using FCM as described in the documentation.
  3. When resetting the configuration to nil, a fatal error may occur in an ongoing task (including warmupCache()) that needs configuration to be present.

    • Likelihood: Won't happen when using FCM as described in the documentation.
  4. When using FCM immediately after it was configured, getAccessToken() may attempt to read gAuth before it has been set by warmupCache(), causing a fatal error.

    • Likelihood: Very unlikely to happen for an HTTP application. Likely to happen for a CLI application or unit tests that use FCM.
  5. When the application is shut down, its storage gets cleared, which may cause a fatal error to occur in an ongoing task (including warmupCache()) that needs configuration or gAuth to be present.

    • Likelihood: Very unlikely to happen for an HTTP application. Likely to happen for unit tests that configure FCM (even without using it).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions