Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/core/src/codewhisperer/client/codewhisperer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class DefaultCodeWhispererClient {
)) as CodeWhispererClient
}

async createUserSdkClient(): Promise<CodeWhispererUserClient> {
async createUserSdkClient(maxRetries?: number): Promise<CodeWhispererUserClient> {
const isOptedOut = CodeWhispererSettings.instance.isOptoutEnabled()
session.setFetchCredentialStart()
const bearerToken = await AuthUtil.instance.getBearerToken()
Expand All @@ -144,6 +144,7 @@ export class DefaultCodeWhispererClient {
apiConfig: userApiConfig,
region: cwsprConfig.region,
endpoint: cwsprConfig.endpoint,
maxRetries: maxRetries,
credentials: new Credentials({ accessKeyId: 'xxx', secretAccessKey: 'xxx' }),
onRequestSetup: [
(req) => {
Expand Down Expand Up @@ -293,7 +294,8 @@ export class DefaultCodeWhispererClient {
public async codeModernizerGetCodeTransformation(
request: CodeWhispererUserClient.GetTransformationRequest
): Promise<PromiseResult<CodeWhispererUserClient.GetTransformationResponse, AWSError>> {
return (await this.createUserSdkClient()).getTransformation(request).promise()
// instead of the default of 3 retries, use 8 retries for this API which is polled every 5 seconds
return (await this.createUserSdkClient(8)).getTransformation(request).promise()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SDK uses 3 retries by default and 100 ms as the base delay during the exponential backoff retry strategy.

This means that if GetTransformation fails after only 0.1 + 0.2 + 0.4 = 0.7 seconds of delays, the transformation is marked as failed on the IDE and users are unable to view the transformation results. Increasing the retries to 8 means that GetTransformation now has a maximum of ~25 seconds of delays.

We have had customer cases where the polling fails, but the transformation eventually succeeds in our backend. This PR should increase the likelihood that those customers are able to view the transformation results.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8 is admittedly arbitrary, and perhaps there's a better way to solve this problem, but I do think that permitting more than 0.7 seconds of delays is a good idea for this specific API. Open to other suggestions.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going to ask why 8, but thank you for explaining that!

}

/**
Expand Down
Loading