Skip to content

Commit 2c5ea56

Browse files
authored
fix(amazonq): Amazon Q chat should not mention indexing in progress when indexing finished (#5062)
* adjust LSP API timeout * update time
1 parent 33bdc9b commit 2c5ea56

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type" : "bugfix",
3+
"description" : "Fix a bug when Amazon Q responds with still indexing message even when `@workspace` index is done"
4+
}

plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/project/ProjectContextProvider.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import java.net.HttpURLConnection
3636
import java.net.URL
3737
import java.util.concurrent.atomic.AtomicBoolean
3838
import java.util.concurrent.atomic.AtomicInteger
39+
import kotlin.time.Duration.Companion.minutes
3940

4041
class ProjectContextProvider(val project: Project, private val encoderServer: EncoderServer, private val cs: CoroutineScope) : Disposable {
4142
private val retryCount = AtomicInteger(0)
@@ -218,9 +219,9 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
218219
)
219220
}
220221

221-
private fun setConnectionTimeout(connection: HttpURLConnection) {
222-
connection.connectTimeout = 5000 // 5 seconds
223-
connection.readTimeout = 5000 // 5 second
222+
private fun setConnectionTimeout(connection: HttpURLConnection, timeout: Int) {
223+
connection.connectTimeout = timeout
224+
connection.readTimeout = timeout
224225
}
225226

226227
private fun setConnectionProperties(connection: HttpURLConnection) {
@@ -311,10 +312,11 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
311312
private fun sendMsgToLsp(msgType: LspMessage, request: String?): LspResponse {
312313
logger.info { "sending message: ${msgType.endpoint} to lsp on port ${encoderServer.port}" }
313314
val url = URL("http://localhost:${encoderServer.port}/${msgType.endpoint}")
314-
315+
// use 1h as timeout for index, 5 seconds for other APIs
316+
val timeoutMs = if (msgType is LspMessage.Index) 60.minutes.inWholeMilliseconds.toInt() else 5000
315317
return with(url.openConnection() as HttpURLConnection) {
316318
setConnectionProperties(this)
317-
setConnectionTimeout(this)
319+
setConnectionTimeout(this, timeoutMs)
318320
request?.let { r ->
319321
setConnectionRequest(this, r)
320322
}

0 commit comments

Comments
 (0)