Skip to content

Commit 1deeeac

Browse files
authored
fix(chat): longer responses throwing ECONNRESET (aws#6969)
## Problem Longer streaming responses are throwing ECONNRESET ## Solution Increase the default timeout --- - Treat all work as PUBLIC. Private `feature/x` branches will not be squash-merged at release time. - Your code changes must meet the guidelines in [CONTRIBUTING.md](https://github.com/aws/aws-toolkit-vscode/blob/master/CONTRIBUTING.md#guidelines). - License: I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 254e005 commit 1deeeac

File tree

4 files changed

+10
-18
lines changed

4 files changed

+10
-18
lines changed

packages/amazonq/src/inlineChat/provider/inlineChatProvider.ts

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { codeWhispererClient } from 'aws-core-vscode/codewhisperer'
2525
import type { InlineChatEvent } from 'aws-core-vscode/codewhisperer'
2626
import { InlineTask } from '../controller/inlineTask'
2727
import { extractAuthFollowUp } from 'aws-core-vscode/amazonq'
28+
import { defaultContextLengths } from 'aws-core-vscode/codewhispererChat'
2829

2930
export class InlineChatProvider {
3031
private readonly editorContextExtractor: EditorContextExtractor
@@ -71,24 +72,7 @@ export class InlineChatProvider {
7172
additionalContents: [],
7273
documentReferences: [],
7374
useRelevantDocuments: false,
74-
contextLengths: {
75-
additionalContextLengths: {
76-
fileContextLength: 0,
77-
promptContextLength: 0,
78-
ruleContextLength: 0,
79-
},
80-
truncatedAdditionalContextLengths: {
81-
fileContextLength: 0,
82-
promptContextLength: 0,
83-
ruleContextLength: 0,
84-
},
85-
workspaceContextLength: 0,
86-
truncatedWorkspaceContextLength: 0,
87-
userInputContextLength: 0,
88-
truncatedUserInputContextLength: 0,
89-
focusFileContextLength: 0,
90-
truncatedFocusFileContextLength: 0,
91-
},
75+
contextLengths: defaultContextLengths,
9276
},
9377
triggerID
9478
)

packages/core/src/codewhispererChat/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,5 @@ export const defaultContextLengths: ContextLengths = {
5353
focusFileContextLength: 0,
5454
truncatedFocusFileContextLength: 0,
5555
}
56+
57+
export const defaultStreamingResponseTimeoutInMs = 180_000

packages/core/src/codewhispererChat/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ export { ChatSessionStorage } from './storages/chatSession'
1515
export { TriggerEventsStorage } from './storages/triggerEvents'
1616
export { ReferenceLogController } from './view/messages/referenceLogController'
1717
export { extractLanguageNameFromFile } from './editor/context/file/languages'
18+
export { defaultContextLengths } from './constants'

packages/core/src/shared/clients/codewhispererChatClient.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ConfiguredRetryStrategy } from '@smithy/util-retry'
77
import { getCodewhispererConfig } from '../../codewhisperer/client/codewhisperer'
88
import { AuthUtil } from '../../codewhisperer/util/authUtil'
99
import { getUserAgent } from '../telemetry/util'
10+
import { defaultStreamingResponseTimeoutInMs } from '../../codewhispererChat/constants'
1011

1112
// Create a client for featureDev streaming based off of aws sdk v3
1213
export async function createCodeWhispererChatStreamingClient(): Promise<CodeWhispererStreaming> {
@@ -17,6 +18,10 @@ export async function createCodeWhispererChatStreamingClient(): Promise<CodeWhis
1718
endpoint: cwsprConfig.endpoint,
1819
token: { token: bearerToken },
1920
customUserAgent: getUserAgent(),
21+
requestHandler: {
22+
timeoutInMs: defaultStreamingResponseTimeoutInMs,
23+
connectionTimeout: defaultStreamingResponseTimeoutInMs,
24+
},
2025
retryStrategy: new ConfiguredRetryStrategy(1, (attempt: number) => 500 + attempt ** 10),
2126
})
2227
return streamingClient

0 commit comments

Comments
 (0)