aws-amplify / amplify-flutter

A declarative library with an easy-to-use interface for building Flutter applications on AWS.
https://docs.amplify.aws
Apache License 2.0
1.31k stars 245 forks source link

Intermittent Issue - Cannot read properties of undefined (reading 'permission_types') #5342

Closed markjoseultra closed 1 month ago

markjoseultra commented 1 month ago

Description

Hi Team,

We keep getting this error but it resolves itself, earlier today all our users experience at the same time and there is a downtime of an hour then it got resolved again and none of us created a fix so it remains a mystery.

Categories

Steps to Reproduce

  1. Try doing a stress test on amplify query and mutate since it doesn't happen all the time.
  2. Use an error monitoring system like sentry.

Screenshots

image image

Platforms

Flutter Version

3.22.2

Amplify Flutter Version

2.1.0

Deployment Method

AWS CDK

Schema

No response

NikaHsn commented 1 month ago

Sorry that you are facing this issue and thanks for reporting it. We will look into this and get back to you when we have updates. meanwhile do you have more detailed error messages to share with us?

Jordan-Nelson commented 1 month ago

@markjoseultra Without more info we are not going to be able to triage this issue. aws_amplify_impl.dart and AWSAmplifyImpl are not part of our code base. If those are files in your app, please share them so we can see the code causing the issue.

markjoseultra commented 1 month ago

Hi Team here is the code that triggers the error previously, now it works but please continue the investigation

 Future<Map<String, dynamic>> query(
    String query,
    Map<String, dynamic> variables,
  ) async {
    try {
      var operation = Amplify.API.query(
        request: GraphQLRequest<String>(
          document: query,
          variables: variables,
          apiName: "ticklr-lambda",
          headers: {
            "Authorization": await LambdaToken.generate(),
          },
        ),
      );

      var response = await operation.response.timeout(
          Duration(minutes: AppConfig.REMOTE_REQUEST_TIMELIMIT), onTimeout: () {
        throw Exception('Weak internet connection, please try again');
      });

      if (response.hasErrors) {
        throw Exception(response.errors[0].message);
      }

      if (response.data == null && response.data!.isEmpty) {
        throw Exception('Unable to fetch data from server, please try again.');
      }

      String? data = response.data;

      return jsonDecode('$data');
    } on GraphQLResponseError catch (e) {
      throw Exception(e.message.toString());
    } on ApiException catch (e) {
      throw Exception(e.message.toString());
    } on LambdaException catch (e) {
      throw Exception(e.message.toString());
    } catch (e) {
      rethrow;
    }
  }
Jordan-Nelson commented 1 month ago

@markjoseultra Thanks for sharing the code. Without reproducible steps or a stack trace that indicates the error is generated from Amplify Flutter we will not be able to investigate. Let us know if you can provide reproducible steps. Otherwise we will close this out. We can re-open in the future if you are able to provide more info.

github-actions[bot] commented 1 month ago

This issue is now closed. Comments on closed issues are hard for our team to see. If you need more assistance, please open a new issue that references this one.