amplify-flutter
amplify-flutter copied to clipboard
issue with "User-Agent was already configured successfully"
Description
This issue is related to amplify_datastore.dart file.
in method:
@override
Future<void> configure({
AmplifyOutputs? config,
required AmplifyAuthProviderRepository authProviderRepo,
}) async {
...
}
this code:
try {
final nativeBridge = NativeAmplifyBridge();
await nativeBridge.configure(
Amplify.version,
jsonEncode(config.toJson()),
);
} on PlatformException catch (e) {
if (e.code == 'AmplifyException') {
throw AmplifyException.fromMap(
Map<String, String>.from(e.details as Map),
);
...
so this line Map<String, String>.from(e.details as Map)
throws error (type 'Null' is not a subtype of type 'Map<dynamic, dynamic>' in type cast) because e.details can be null.
in my case PlatformException contains this information
PlatformException(
AmplifyException,
AmplifyException{message=User-Agent was already configured successfully.,
cause=null,
recoverySuggestion=User-Agent is configured internally during Amplify configuration. This method should not be called externally.},
null,
null
)
(as you can see e.details
field is null
there)
I would suggest to ignore this "User-Agent was already configured successfully" error, because for example in my case I'm initializing Amplify from the main UI thread, but there is also a possibility that some separate isolate is launched and it tries to initialize Amplify as well (have to deal with background services). Since there is no way to detect from one isolate that Amplify was already configured in another isolate - I end up having this issue.
Categories
- [ ] Analytics
- [ ] API (REST)
- [ ] API (GraphQL)
- [ ] Auth
- [ ] Authenticator
- [X] DataStore
- [ ] Notifications (Push)
- [ ] Storage
Steps to Reproduce
- Register Amplify with DataStore plugin in main isolate
- Register Amplify with DataStore plugin in different isolate
Screenshots
No response
Platforms
- [ ] iOS
- [X] Android
- [ ] Web
- [ ] macOS
- [ ] Windows
- [ ] Linux
Flutter Version
3.24.0-0.2.pre
Amplify Flutter Version
3.2.0
Deployment Method
Amplify CLI
Schema
No response