diff --git a/packages/core/src/codewhisperer/util/editorContext.ts b/packages/core/src/codewhisperer/util/editorContext.ts index 1176eaea59e..4b58cb4f848 100644 --- a/packages/core/src/codewhisperer/util/editorContext.ts +++ b/packages/core/src/codewhisperer/util/editorContext.ts @@ -130,9 +130,11 @@ export async function buildGenerateRecommendationRequest(editor: vscode.TextEdit const fileContext = extractContextForCodeWhisperer(editor) const tokenSource = new vscode.CancellationTokenSource() + // the supplement context fetch mechanisms each has a timeout of supplementalContextTimeoutInMs + // adding 10 ms for overall timeout as buffer setTimeout(() => { tokenSource.cancel() - }, supplementalContextTimeoutInMs) + }, supplementalContextTimeoutInMs + 10) const supplementalContexts = await fetchSupplementalContext(editor, tokenSource.token) logSupplementalContext(supplementalContexts) diff --git a/packages/core/src/codewhisperer/util/supplementalContext/crossFileContextUtil.ts b/packages/core/src/codewhisperer/util/supplementalContext/crossFileContextUtil.ts index 8ef6b9841cd..ee1a82b4cdc 100644 --- a/packages/core/src/codewhisperer/util/supplementalContext/crossFileContextUtil.ts +++ b/packages/core/src/codewhisperer/util/supplementalContext/crossFileContextUtil.ts @@ -71,13 +71,13 @@ export async function fetchSupplementalContextForSrc( async function () { return await fetchSupplementalContextForSrcV1(editor, cancellationToken) }, - { timeout: supplementalContextTimeoutInMs, interval: 10, truthy: false } + { timeout: supplementalContextTimeoutInMs, interval: 5, truthy: false } ) const promiseV2 = waitUntil( async function () { return await fetchSupplementalContextForSrcV2(editor) }, - { timeout: supplementalContextTimeoutInMs, interval: 10, truthy: false } + { timeout: supplementalContextTimeoutInMs, interval: 5, truthy: false } ) const [resultV1, resultV2] = await Promise.all([promiseV1, promiseV2]) return resultV2 ?? resultV1