Code Monkey home page Code Monkey logo

Comments (8)

Equartey avatar Equartey commented on June 8, 2024 1

@mettamdaica0909

I did. But seems the network inspector can not detect the request in v0.6, it can detect the request in v1+. I think the network inspector can not detect the request that is executed in the native code.

I'm more interested in the amount of requests being sent from your V1 project. It's easiest to grab that info from web if you have that platform enabled in your project. Let us know how many requests you see and we can continue to debug.

It means the lib always performs a network request for the user's information. correct?

Correct. This is by design. You're welcome to cache it yourself, as we will always fetch from remote when you call the API.

btw, can we change the limitation (120 requests per sec) to a higher value?

Where are you seeing this limit?

from amplify-flutter.

Equartey avatar Equartey commented on June 8, 2024

Hi @mettamdaica0909, sorry to hear you ran into an issue during migration.

Can you confirm if you're using the Authenticator UI component? Or are you using the Auth category directly?

from amplify-flutter.

mettamdaica0909 avatar mettamdaica0909 commented on June 8, 2024

I'm using the Auth category directly. I checked both version and seem there's an update for the fetchUserAttributes function.

Ver 0.6.0

@override
  Future<List<AuthUserAttribute>>  #fetchUserAttributes(
      {FetchUserAttributesRequest? request}) async {
    try {
      final List<Map<dynamic, dynamic>>? data =
          (await (_channel.invokeListMethod(
        'fetchUserAttributes',
        <String, dynamic>{
          'data': request != null ? request.serializeAsMap() : {},
        },
      )));
      if (data == null)
        throw AmplifyException(
            AmplifyExceptionMessages.nullReturnedFromMethodChannel);
      return formatFetchAttributesResponse(data);
    } on PlatformException catch (e) {
      throw castAndReturnPlatformException(e);
    }
  }

Ver 1.6.1

Future<List<AuthUserAttribute>> fetchUserAttributes({
    FetchUserAttributesOptions? options,
  }) async {
    final tokens = await stateMachine.getUserPoolTokens();
    final resp = await _cognitoIdp
        .getUser(
          cognito.GetUserRequest(
            accessToken: tokens.accessToken.raw,
          ),
        )
        .result;
    return [
      for (final attributeType in resp.userAttributes)
        attributeType.asAuthUserAttribute,
    ];
  }

My understanding is 1.6.1 version is hitting the server for the attributes via cognito.GetUserRequest. is that correct?

from amplify-flutter.

Equartey avatar Equartey commented on June 8, 2024

Hi @mettamdaica0909, that's a correct observation, the implementation has changed between major versions.

In v0.6, we were calling into the native platform libraries to perform the API call. For example, on iOS devices the Amplify Swift library would handle to request through the method channel.

In v1+, we perform the entire fetchUserAttributes() call in Dart using Amplify Flutter's Dart API category.

There is also no cache. Each call to the API will perform a network request. This was also the behavior in V0.6.

As for the error you're seeing, I can not reasonably reproduce it. If I throw fetchUserAttributes() in a loop and call it 100 times, they all succeed. Bumping that number up to 500 I start to see failures. In either case, that amount of calls seems unlikely in a normal app.

I suspect something else is going on. Can you confirm the following:

  1. Using a network inspector, how many requests are made before you see this exception?
  2. Does this happen on any device/OS?
  3. Can you reproduce it on a fresh project? If so, please provide the reproduction steps.

from amplify-flutter.

mettamdaica0909 avatar mettamdaica0909 commented on June 8, 2024

Hi @Equartey, Thanks for your quick response.

Using a network inspector, how many requests are made before you see this exception?
-> I did. But seems the network inspector can not detect the request in v0.6, it can detect the request in v1+. I think the network inspector can not detect the request that is executed in the native code.

There is also no cache. Each call to the API will perform a network request. This was also the behavior in V0.6.
-> It means the lib always performs a network request for the user's information. correct?

from amplify-flutter.

mettamdaica0909 avatar mettamdaica0909 commented on June 8, 2024

btw, can we change the limitation (120 requests per sec) to a higher value?

from amplify-flutter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.