feat(auth): Refuse addPlugin from a secondary isolate without a messenger (#5302) - #7272
Draft
cadivus wants to merge 1 commit into
Draft
feat(auth): Refuse addPlugin from a secondary isolate without a messenger (#5302)#7272cadivus wants to merge 1 commit into
cadivus wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat/isolate-guard-datastore #7272 +/- ##
================================================================
+ Coverage 32.68% 41.08% +8.40%
================================================================
Files 34 126 +92
Lines 2374 8331 +5957
Branches 915 3632 +2717
================================================================
+ Hits 776 3423 +2647
- Misses 1598 4908 +3310 🚀 New features to boost your workflow:
|
…nger (#5302) Second of the per-category #5302 guardrails. `AmplifyAuthCognito.addPlugin` registers with the process-wide native Cognito SDK, starting with `NativeAuthPlugin.setUp`. Without a guard a secondary isolate got a bare `StateError` about `BackgroundIsolateBinaryMessenger` from inside Pigeon, which says nothing about Amplify, Auth or isolates. Gated on messenger availability rather than root-isolate identity. A headless `FlutterEngine` always has a working messenger, so the guard provably cannot fire there -- which matters because `amplifyBackgroundProcessing` adds this very plugin from such an engine. The broader root-token check would have rested on an unverified claim about headless engines, and the cost of being wrong is broken push handling in shipped apps. No duplicated predicate: amplify_auth_cognito already depends on amplify_flutter, so it imports the canonical `@internal` getter directly. Documents, in code and in an executable test, that this does not catch a secondary isolate which has already been bootstrapped with a messenger. That case cannot work regardless: Flutter itself refuses it with `UnsupportedError: Background isolates do not support setMessageHandler(). Messages from the host platform always go to the root isolate.` Host-to-Dart callbacks are impossible off the root isolate, which bounds what #5302 can ever support.
cadivus
force-pushed
the
feat/isolate-guard-auth
branch
from
August 12, 2026 17:21
eb72956 to
cc4f6dd
Compare
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.
Second per-category guardrail for #5302, stacked on #7271.
AmplifyAuthCognito.addPluginnow throws aPluginErrornaming the cause instead of letting a bareStateErrorescape from inside Pigeon. Gated on messenger availability, not root-isolate identity: a headlessFlutterEnginealways has a messenger, so the guard provably cannot fire inamplifyBackgroundProcessing— which adds this very plugin from such an engine. The broader check would have rested on an unverified claim, and being wrong there breaks push handling in shipped apps.amplify_auth_cognitoalready depends onamplify_flutter, so it imports the canonical@internalgetter. Duplication stays at n=1 (amplify_datastoreonly).UnsupportedError: Background isolates do not support setMessageHandler(). Messages from the host platform always go to the root isolate.Host-to-Dart callbacks are impossible off the root isolate, which bounds what Isolate Support #5302 can ever support.amplify_auth_cognitosuite green.Follow-up not in this stack: the push guard is deferred — it needs an
integration_test/harness, ane2e_androidleg, and a test-only native hook to invoke the background service and report the predicate. Native work with its own testing plan.