Open abhirpat opened 1 year ago
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 https://github.com/awslabs/aws-sdk-js-codemod/issues/53#issuecomment-1366081340
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)
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.
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.
The comment you mentioned would help.
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)
Self-service
Describe the bug
SDK V2 to V3 migration using codemod is adding extra time which is causing performance issues.
transformed by codemod
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
Additional context
No response