Skip to content

fix(clerk_auth): offline sign out#403

Open
MarkOSullivan94 wants to merge 3 commits into
mainfrom
401-offline-sign-out
Open

fix(clerk_auth): offline sign out#403
MarkOSullivan94 wants to merge 3 commits into
mainfrom
401-offline-sign-out

Conversation

@MarkOSullivan94
Copy link
Copy Markdown
Collaborator

Resolves #401

This pull request addresses a critical bug in the sign-out flow when the device is offline and improves test support for simulating network conditions. The main fix ensures that local authentication state and credentials are cleared immediately during sign-out, even if the network is unavailable, preventing unintended silent re-authentication when connectivity returns. Additional changes enhance the mock HTTP service to better support offline scenarios and make tests more comprehensive and reliable.

Bug Fixes:

  • Ensure _tokenCache.clear() is called at the start of the _delete method in Api, so credentials are cleared immediately during sign-out, regardless of network success or failure. [1] [2]

Test Infrastructure Improvements:

  • Add the isOffline flag to MockHttpService to simulate offline behavior, causing network calls to throw a SocketException and ping to return false. [1] [2] [3]
  • Add a helper method addAuthenticatedClientWithSessionResponse to MockHttpService for easier setup of authenticated client states in tests.
  • Ensure reset() also resets the isOffline flag in MockHttpService.

New Tests:

  • Add sign_out_offline_test.dart to verify that signing out while offline clears credentials and prevents silent re-authentication when connectivity returns, and that no credentials are sent in subsequent requests.

Test Configuration:

  • Add a valid test publishable key constant and set default retry options in TestAuthConfig for more predictable test behavior.

@MarkOSullivan94 MarkOSullivan94 self-assigned this May 8, 2026
@MarkOSullivan94 MarkOSullivan94 added the clerk_auth package: clerk_auth label May 8, 2026
@MarkOSullivan94 MarkOSullivan94 requested a review from slightfoot May 8, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clerk_auth package: clerk_auth

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Offline sign out

1 participant