Skip to content

Commit cf88282

Browse files
authored
fix(amazonq): increase timeout for project index init (#1005)
1 parent 1457cb3 commit cf88282

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

server/aws-lsp-codewhisperer/src/shared/localProjectContextController.test.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { LocalProjectContextController } from './localProjectContextController'
2-
import { SinonStub, stub, assert as sinonAssert, match, restore } from 'sinon'
2+
import { SinonStub, stub, assert as sinonAssert, match, restore, spy } from 'sinon'
33
import * as assert from 'assert'
44
import * as fs from 'fs'
55
import { Dirent } from 'fs'
@@ -75,12 +75,13 @@ describe('LocalProjectContextController', () => {
7575

7676
describe('init', () => {
7777
it('should initialize vector library successfully', async () => {
78+
const buildIndexSpy = spy(controller, 'buildIndex')
7879
await controller.init({ vectorLib: vectorLibMock })
7980

8081
sinonAssert.notCalled(logging.error)
8182
sinonAssert.called(vectorLibMock.start)
8283
const vecLib = await vectorLibMock.start()
83-
sinonAssert.called(vecLib.buildIndex)
84+
sinonAssert.called(buildIndexSpy)
8485
})
8586

8687
it('should handle initialization errors', async () => {
@@ -92,6 +93,15 @@ describe('LocalProjectContextController', () => {
9293
})
9394
})
9495

96+
describe('buildIndex', () => {
97+
it('should build Index with vectorLib', async () => {
98+
await controller.init({ vectorLib: vectorLibMock })
99+
const vecLib = await vectorLibMock.start()
100+
await controller.buildIndex()
101+
sinonAssert.called(vecLib.buildIndex)
102+
})
103+
})
104+
95105
describe('queryVectorIndex', () => {
96106
beforeEach(async () => {
97107
await controller.init({ vectorLib: vectorLibMock })

server/aws-lsp-codewhisperer/src/shared/localProjectContextController.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export class LocalProjectContextController {
111111
const vecLib = vectorLib ?? (await import(libraryPath))
112112
if (vecLib) {
113113
this._vecLib = await vecLib.start(LIBRARY_DIR, this.clientName, this.indexCacheDirPath)
114-
await this.buildIndex()
114+
void this.buildIndex()
115115
LocalProjectContextController.instance = this
116116
} else {
117117
this.log.warn(`Vector library could not be imported from: ${libraryPath}`)
@@ -140,7 +140,8 @@ export class LocalProjectContextController {
140140
}
141141
}
142142

143-
private async buildIndex(): Promise<void> {
143+
// public for test
144+
async buildIndex(): Promise<void> {
144145
try {
145146
if (this._vecLib) {
146147
const sourceFiles = await this.processWorkspaceFolders(

0 commit comments

Comments
 (0)