Skip to content

Commit 7987955

Browse files
committed
adjust LSP API timeout
1 parent ad03841 commit 7987955

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-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: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
217217
)
218218
}
219219

220-
private fun setConnectionTimeout(connection: HttpURLConnection) {
221-
connection.connectTimeout = 5000 // 5 seconds
222-
connection.readTimeout = 5000 // 5 second
220+
private fun setConnectionTimeout(connection: HttpURLConnection, timeout: Int) {
221+
connection.connectTimeout = timeout
222+
connection.readTimeout = timeout
223223
}
224224

225225
private fun setConnectionProperties(connection: HttpURLConnection) {
@@ -310,10 +310,11 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
310310
private fun sendMsgToLsp(msgType: LspMessage, request: String?): LspResponse {
311311
logger.info { "sending message: ${msgType.endpoint} to lsp on port ${encoderServer.port}" }
312312
val url = URL("http://localhost:${encoderServer.port}/${msgType.endpoint}")
313-
313+
// use 1h as timeout for index, 5 seconds for other APIs
314+
val timeoutMs = if (msgType is LspMessage.Index) 3600*1000 else 5000
314315
return with(url.openConnection() as HttpURLConnection) {
315316
setConnectionProperties(this)
316-
setConnectionTimeout(this)
317+
setConnectionTimeout(this, timeoutMs)
317318
request?.let { r ->
318319
setConnectionRequest(this, r)
319320
}

0 commit comments

Comments
 (0)