Skip to content

Commit 886ab29

Browse files
authored
config(amazonq): adjust timeout for supplemental context #5978
## Problem The overall supplemental context has a timeout of 50ms, each sub promise has a timeout of 50ms. Problem is these 2 timeout are very tight, leaving no buffer time for node js runtime to do context switch. The poll interval of each sub promise is 10ms, which does not precisely timeout at 50ms. ## Solution Add a 10ms buffer time for supplemental context. Reduce poll duration
1 parent c09b09a commit 886ab29

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

packages/core/src/codewhisperer/util/editorContext.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,11 @@ export async function buildGenerateRecommendationRequest(editor: vscode.TextEdit
130130
const fileContext = extractContextForCodeWhisperer(editor)
131131

132132
const tokenSource = new vscode.CancellationTokenSource()
133+
// the supplement context fetch mechanisms each has a timeout of supplementalContextTimeoutInMs
134+
// adding 10 ms for overall timeout as buffer
133135
setTimeout(() => {
134136
tokenSource.cancel()
135-
}, supplementalContextTimeoutInMs)
137+
}, supplementalContextTimeoutInMs + 10)
136138
const supplementalContexts = await fetchSupplementalContext(editor, tokenSource.token)
137139

138140
logSupplementalContext(supplementalContexts)

packages/core/src/codewhisperer/util/supplementalContext/crossFileContextUtil.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,13 @@ export async function fetchSupplementalContextForSrc(
7171
async function () {
7272
return await fetchSupplementalContextForSrcV1(editor, cancellationToken)
7373
},
74-
{ timeout: supplementalContextTimeoutInMs, interval: 10, truthy: false }
74+
{ timeout: supplementalContextTimeoutInMs, interval: 5, truthy: false }
7575
)
7676
const promiseV2 = waitUntil(
7777
async function () {
7878
return await fetchSupplementalContextForSrcV2(editor)
7979
},
80-
{ timeout: supplementalContextTimeoutInMs, interval: 10, truthy: false }
80+
{ timeout: supplementalContextTimeoutInMs, interval: 5, truthy: false }
8181
)
8282
const [resultV1, resultV2] = await Promise.all([promiseV1, promiseV2])
8383
return resultV2 ?? resultV1

0 commit comments

Comments
 (0)