iOS: surface SystemIsBusy/SessionTerminatedUnexpectedly and fix UserCanceled#234
Open
Klievan wants to merge 2 commits into
Open
iOS: surface SystemIsBusy/SessionTerminatedUnexpectedly and fix UserCanceled#234Klievan wants to merge 2 commits into
Klievan wants to merge 2 commits into
Conversation
…anceled Session-invalidation errors were only delivered to a pending `poll`; any in-flight tag operation (transceive/readNDEF/writeNDEF/...) used a local result closure, so when the user canceled after a tag was polled the `UserCanceled` error was dropped by the `guard result != nil` check — the Future hung or surfaced the operation's generic 500 instead. - Add a single `mapNFCError` mapper covering UserCanceled (409), SessionTimeOut (408), SystemIsBusy (503) and SessionTerminatedUnexpectedly (502); previously the latter two fell through to a generic 500. - Route in-flight operations through a fire-once `trackResult` wrapper so `didInvalidateWithError` completes the pending call exactly once. - Rename the 409 message `SessionCanceled` -> `UserCanceled`. - Example: add a "Session error test" section (stream dummy data to keep the session busy for UserCanceled; drive the kick-off -> instant retry -> backoff flow for SystemIsBusy). - Document the iOS session-error codes in README and CHANGELOG.
iOS: surface SystemIsBusy/SessionTerminatedUnexpectedly and fix UserCanceled
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On iOS, CoreNFC session-invalidation errors were only delivered to a pending
poll. Every in-flight tag operation (transceive,readNDEF,writeNDEF,readBlock,writeBlock,makeNdefReadOnly) used a local result closure and never setself.result, so after a tag was polled:guard result != nil else { return }indidInvalidateWithErrorand was silently dropped. The consumer saw the operation's generic500comm error instead ofUserCanceled.SystemIsBusyandSessionTerminatedUnexpectedlyhad no mapping and fell through to a generic500.Changes
mapNFCError: single source of truth mapping CoreNFC errors to HTTP-style codes:409 UserCanceled,408 SessionTimeOut,503 SystemIsBusy,502 SessionTerminatedUnexpectedly.trackResult: fire-once wrapper; in-flight operations now route throughself.result, sodidInvalidateWithErrorcompletes the pending call exactly once (no hang, no masked500).409messageSessionCanceled→UserCanceled.transceive(validatesUserCanceled); Test SystemIsBusy drives the real kick-off (502) → instant retry (503) → backoff → recover flow.Codes follow the existing HTTP-style
PlatformExceptionconvention (no new Dart API). The only behavior change is the409message rename (SessionCanceled→UserCanceled), noted in the CHANGELOG.Testing
flutter analyzeclean;flutter build ios --no-codesigncompiles. Validated on-device: cancel mid-stream returns409 UserCanceled; the SystemIsBusy flow surfaces502on kick-off and503on instant retry, recovering after a backoff.