Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adminInitiateAuth call is taking longer time to respond for first call #4460

Open
gokul-ilango opened this issue Jul 4, 2023 · 3 comments
Open
Assignees
Labels
bug This issue is a bug. p2 This is a standard priority issue

Comments

@gokul-ilango
Copy link

Describe the bug

cognitoidentityserviceprovider.adminInitiateAuth call is taking around 10 Seconds to respond for first time. The successive calls are getting resolved faster like in 2 Seconds.

function _loginUserToUserPool() {
    return new Promise (function (resolve, reject) {
        try {
            const params = {
                AuthFlow: 'ADMIN_USER_PASSWORD_AUTH',
                ClientId: '**************',
                UserPoolId: '**************',
                AuthParameters: {
                    USERNAME: 'xyz@email.com',
                    PASSWORD: 'password123'
                }
            };
            let startTime = new Date().getTime();
            cognitoidentityserviceprovider.adminInitiateAuth(params, function(error, data) {
                let diff = (new Date().getTime() - startTime) / 1000;
                console.log("time taken in seconds: "+ diff);
                if (error){
                    reject(error);
                }
                resolve(data)
            })
        }
        catch(err){
            reject(err);
        }
    })
}

_loginUserToUserPool();

Note:

  1. This issue is not present in sdk version 2.361.0
  2. issue noticed after upgrading the version to 2.618.0
  3. tried v3 version of the SDKs as well. same issue is noticed

Expected Behavior

run the above code block and expected lesser latency

run 1: time taken in seconds: 1.717
run 2: time taken in seconds: 1.803

Current Behavior

first call takes longer time to resolve

run 1: time taken in seconds: 10.341
run 2: time taken in seconds: 1.717
run 3: time taken in seconds: 1.803

Reproduction Steps

please run the code block in description in Node Js env.

Possible Solution

No response

Additional Information/Context

No response

SDK version used

2.1406.0

Environment details (OS name and version, etc.)

Windows 10, Node 16.16.0, npm 6.14.15

@gokul-ilango gokul-ilango added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 4, 2023
@yenfryherrerafeliz
Copy link

Hi @gokul-ilango, sorry to hear about your issues. I think this behavior may be caused by the default credentials resolution, which will go over each credentials provider set in the default chain, and once the credentials are resolved the first time then, the subsequent calls will reuse those credentials and therefore you notice those calls take less than the first call. Could you please confirm which credentials provider are you using?, and would it be possible for you to explicit set it when instancing the client?. For example, lets assume your credentials are from environment then, you could the following:

import AWS from "aws-sdk";

const client = new AWS.CognitoIdentityServiceProvider({
    credentials: new AWS.EnvironmentCredentials(""),
    region: "us-east-2"
});

Please let me know if this help!

Thanks!

@yenfryherrerafeliz yenfryherrerafeliz added response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. p2 This is a standard priority issue and removed needs-triage This issue or PR still needs to be triaged. labels Jul 17, 2023
@yenfryherrerafeliz yenfryherrerafeliz self-assigned this Jul 17, 2023
@github-actions
Copy link

This issue has not received a response in 1 week. If you still think there is a problem, please leave a comment to avoid the issue from automatically closing.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jul 23, 2023
@gokul-ilango
Copy link
Author

even after using credentials parameter explicitly, the issue exists.

set the following env variables SET AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN
created client with 'AWS' env prefix

 const client = new AWS.CognitoIdentityServiceProvider({
    credentials: new AWS.EnvironmentCredentials("AWS"),
    region: "us-east-2"
});

still seeing same issue,
First call : 12.749 seconds
Second call: 2.234 seconds

@github-actions github-actions bot removed closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to \"closing-soon\" in 7 days. labels Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. p2 This is a standard priority issue
Projects
None yet
Development

No branches or pull requests

2 participants