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

S3 waitFor adding extra delay which changes application behavior #737

Open
1 task
abhirpat opened this issue Nov 20, 2023 · 5 comments
Open
1 task

S3 waitFor adding extra delay which changes application behavior #737

abhirpat opened this issue Nov 20, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@abhirpat
Copy link

abhirpat commented Nov 20, 2023

Self-service

  • I'd be willing to implement a fix

Describe the bug

SDK V2 to V3 migration using codemod is adding extra time which is causing performance issues.

await s3.waitFor('objectExists', param).promise();

transformed by codemod

await waitUntilObjectExists({
           client: s3,
           maxWaitTime: 200
       }, param)

The codemod adds maxWaitTime: 200 which is changing the code behavior and causing performance issues

Steps to reproduce

Try to reproduce using the provided description for command.

Observed behavior

The command waits for 200 seconds which is adding significant delay.

Expected behavior

The code would execute instantly before.

Environment

aws-sdk-js-codemod: 0.26.3
- jscodeshift: 0.15.0
- recast: 0.23.4

Additional context

No response

@abhirpat abhirpat added bug Something isn't working triage Triaging bugs labels Nov 20, 2023
@abhirpat abhirpat changed the title [Bug?]: maxWaitTime: 200 S3 waitFor adding extra delay which changes application behavior Nov 20, 2023
@trivikr
Copy link
Member

trivikr commented Nov 20, 2023

The maxWaitTime does not cause any performance issues. It's just a default value which is required in JS SDK v3 waiters.
More details in #53 (comment)

Would adding the following comment help?

await waitUntilObjectExists({
   client: s3,
   // Maximum wait time is required in waiters.
   // Codemod uses 200 seconds as default.
   maxWaitTime: 200
 }, params)

@trivikr trivikr added enhancement New feature or request and removed triage Triaging bugs bug Something isn't working labels Nov 20, 2023
@trivikr
Copy link
Member

trivikr commented Nov 20, 2023

The performance issues in waiters, if any, may be caused by retry behavior of waiters.

Please create a bug report on aws-sdk-js-v3 repo if you're seeing some concrete differences between v2 and v3 waiters with a minimal repro.

@abhirpat
Copy link
Author

abhirpat commented Nov 20, 2023

Could you please observe difference with SDK V2 and V3 when no object exists? I notice it still waits for 200 seconds which was not the case before.

@abhirpat
Copy link
Author

The comment you mentioned would help.

@abhirpat
Copy link
Author

Today, I was able to see that SDK V2 exists immediately when file doesn't exist. Reproduced with "aws-sdk": "^2.1505.0".

const region = 'us-east-1'
const { S3Client, waitUntilObjectExists } = require('@aws-sdk/client-s3');

async function sdkv3(params) {
    const { Bucket, Key } = params;
    const s3 = new S3Client({ region });
    try {
        await waitUntilObjectExists({
            client: s3,
            maxWaitTime: 200
        }, {Bucket, Key})
    } catch (error) {
        console.log("Done with V3")
    }
}


async function sdkv2(params) {
    const { Bucket, Key } = params;
    const AWS = require('aws-sdk');
    AWS.config.region = region;
    const s3 = new AWS.S3();
    try {
        await s3.waitFor('objectExists',{Bucket, Key}).promise()
    } catch (error) {
        console.log('Done with V2')
    }
}

const param = {
    Bucket: 'dev-exportbucket-1nvs7qmdel',
    Key: 'filedoesntexist.json'
  };

sdkv2(param)
// sdkv3(param)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants