Comments (8)
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.
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.
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.
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:
- Using a network inspector, how many requests are made before you see this exception?
- Does this happen on any device/OS?
- Can you reproduce it on a fresh project? If so, please provide the reproduction steps.
from amplify-flutter.
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.
btw, can we change the limitation (120 requests per sec) to a higher value?
from amplify-flutter.
Thanks @Equartey
Correct. This is by design. You're welcome to cache it yourself, as we will always fetch from remote when you call the API.
I think this is all I need. In this case, I have to update the code logic to reduce the API calls.
from amplify-flutter.
@mettamdaica0909 No problem. I'm going to close this issue, please reach out again if you have any more questions.
from amplify-flutter.
Related Issues (20)
- NotAuthorizedServiceException when answering NEW_PASSWORD_REQUIRED challenge HOT 7
- Amplify.Hub.listen never get "ready" HOT 6
- correctClockSkew option HOT 1
- Amplify.API.mutate HOT 9
- Customize title of Authentication with Amplify flutter Authentication UI HOT 3
- Network error when trying to authenticate from a release apk HOT 5
- How to use SyncExpression with GroupPredicate HOT 3
- Gen2 - Quick Start guide does not work - ConfigurationError: The provided configuration is not a valid json HOT 3
- Build failed with an exception
- Error message is unclear when oauth is missing from config HOT 3
- [iOS] building with debug flag makes the app crash HOT 3
- aws_signature_v4 - flutter and aws lex bot integration HOT 3
- Data not updated by API GraphQL HOT 3
- Feature Request: GraphQL query with sorting by date with secondary index HOT 7
- DataStore initial sync slower after recreating auth and schema has owner-based permissions HOT 6
- amplify_auth_cognito:compileDebugJavaWithJavac HOT 9
- Datastore query returns empty list even when isSynced: true in observeQuery snapshot. HOT 2
- [aws_common] update the "js" version in pubspec HOT 2
- a.customType({}) modelgen issue - Single-Table-Design flutter Amplify-gen2 HOT 2
- feature request: Emit info from signInWithWebUI through Auth Hub HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amplify-flutter.