Search Results for

    Show / Hide Table of Contents

    Explanation: quarantine

    Purpose: explain why the library blocks new NFC work when it cannot confirm that a resource was released. Platforms: Android, iOS. Status: stable.

    The problem

    Closing a native tag connection or disabling reader mode can fail, hang or finish late. If the library reported success and let the app start again, a new session could run while the old native connection is still open: commands would reach the wrong tag, authentication state would leak between operations, or the controller would stay in a mode the app no longer expects.

    The rule

    When release fails or cannot be confirmed, the owner is quarantined:

    • the operation fails with ResourceFailure (portable.operation.resourceFailure). Known mutation and verification effects are preserved, and the release failure is reported separately in Effects.CleanupError;
    • no new session or connection can be acquired while the quarantine lasts; capability availability reports Busy or Restricted;
    • after five seconds of unresolved cleanup the status reports connection.cleanup.pending, and awaited close or stop returns ResourceFailure. This is an observation deadline, not a forced termination of native I/O;
    • if the original native close and worker finish later, the quarantine is lifted and a still-requested session can resume. A failed close is not retried automatically;
    • DisposeAsync is idempotent and throws IOException if release cannot be confirmed, instead of returning as if everything were released.

    Why not hide it

    A quarantine is visible and rare. Hiding it would turn a temporary, explainable state into silent data corruption or a stuck controller. Expected platform behavior is not quarantined: for example, on Android API 33+ closing a tag that already left the field throws SecurityException ("Tag is out of date"), which the library treats as a confirmed release.

    What this means for your app

    • Show ResourceFailure as "NFC is temporarily unavailable" and offer a restart of the workflow, not an immediate automatic retry.
    • Observe CapabilitiesChanged: availability changes again when the quarantine is lifted.
    • Never assume a write failed because cleanup failed: read Effects.Mutation first.

    Related

    • Ownership and cancellation.
    • Cleanup reason codes: reason codes.
    • Edit this page
    In this article
    Back to top Nementis MAUI NFC documentation