Skip to content

docs: Document the root-isolate requirement for Amplify (#5302) - #7273

Draft
cadivus wants to merge 1 commit into
feat/isolate-guard-authfrom
feat/isolate-secondary-configure-docs-api
Draft

docs: Document the root-isolate requirement for Amplify (#5302)#7273
cadivus wants to merge 1 commit into
feat/isolate-guard-authfrom
feat/isolate-secondary-configure-docs-api

Conversation

@cadivus

@cadivus cadivus commented Aug 12, 2026

Copy link
Copy Markdown
Member

⚠️ This came out as the opposite of what PR4 was scoped to be — please read bullet 3. Stacked on #7272. Docs only, no code change.

  • Documents the constraint the guardrails enforce, in the amplify_flutter README's existing Category / Platform Support section (where platform caveats already live).
  • Framed on the two bounds that actually apply, not a per-category list: (1) platform channels are one-way — a secondary isolate can call into the host but can never receive messages back, so every callback-driven API is permanently root-isolate-only (DataStore observe/Hub, push handlers, Hosted UI redirect, NativeAuthPlugin.setUp); (2) persistent state is shared and unsynchronized — the native SDKs and credential store are one per process and nothing serializes access across isolates.
  • 🛑 I did NOT document "configure in any isolate" as a supported feature, and I recommend we do not. Writing it down honestly showed the safe surface is too thin: writeMany in the credential store is Future.wait over independent per-key writes with no lock, CAS or versioning anywhere in amplify_auth_cognito_dart or amplify_secure_storage*, so two isolates refreshing tokens can interleave per key and leave a mixed credential set (new access token + old refresh token). That is worse than last-write-wins.
  • Consequence: PR2's helper stays @internal and the user-facing contract should land with the broker that makes it safe. Details and the recommended PR5 reframe are in the task report.

Documents the constraint the #5302 guardrails now enforce, in the README's
existing platform-support section. Docs only; no code change.

Written around the two bounds that actually apply, rather than a per-category
list:

- Platform channels only work one way. After
  `BackgroundIsolateBinaryMessenger.ensureInitialized` a secondary isolate can
  call into the host, but never receive messages back -- Flutter delivers host
  messages to the root isolate only. This makes every callback-driven API
  permanently root-isolate-only: DataStore observe and Hub events, push
  notification handlers, Hosted UI redirects, and `NativeAuthPlugin.setUp`.
- Persistent state is shared and unsynchronized. The native SDKs and the
  credential store are one per process, and nothing serializes access across
  isolates.

Deliberately does NOT document "configure in any isolate" as a supported
feature. See the task report: the safe surface is too thin to advertise until a
broker serializes credential access through the root isolate.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (feat/isolate-guard-auth@cc4f6dd). Learn more about missing BASE report.

Additional details and impacted files
@@                    Coverage Diff                     @@
##             feat/isolate-guard-auth    #7273   +/-   ##
==========================================================
  Coverage                           ?   31.61%           
==========================================================
  Files                              ?       25           
  Lines                              ?     2056           
  Branches                           ?      789           
==========================================================
  Hits                               ?      650           
  Misses                             ?     1406           
  Partials                           ?        0           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants