Skip to content

Amplify.Auth.signOut() Fails to Sign Out Locally with UnknownServiceException in Flutter #6205

@AntoniKwok

Description

@AntoniKwok

Description

When calling Amplify.Auth.signOut() in the Flutter app, the sign-out process intermittently fails with an UnknownServiceException and "signedOutLocally": false. The exception message is "An unknown error occurred" with an underlying exception of UnknownSmithyHttpException. This results in the user not being signed out locally, causing further authentication and authorization errors (e.g., 403 responses, malformed authorization headers) until the app is restarted.

  if (result is CognitoSignOutResult) {
    if (result.signedOutLocally) {
      safePrint('Signed out locally.');
    } else {
      safePrint('Sign out failed: ${result.exception}');
    }
  }
  loading.value = false;
}).catchError((e) {
  safePrint('Error signing out: $e');
  AuthEvents.triggerForceLogout('Force Logout from signOut');
}); ```

### Categories

- [ ] Analytics
- [ ] API (REST)
- [ ] API (GraphQL)
- [ ] Auth
- [ ] Authenticator
- [ ] DataStore
- [ ] Notifications (Push)
- [ ] Storage

### Steps to Reproduce

I tried to implement force logout when session expired, and when force logout triggered the logout didn't work properly which can't re-login

### Screenshots

_No response_

### Platforms

- [x] iOS
- [x] Android
- [ ] Web
- [ ] macOS
- [ ] Windows
- [ ] Linux

### Flutter Version

3.24.5

### Amplify Flutter Version

1.7.0

### Deployment Method

Amplify CLI (Gen 1)

### Schema

```GraphQL

Metadata

Metadata

Assignees

Labels

authIssues related to the Auth CategorybugSomething is not working; the issue has reproducible steps and has been reproducedpending-close-response-requiredThe issue will be closed if details necessary to reproduce the issue are not provided within 7 days.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions