Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"type" : "bugfix",
"description" : "Fix a bug when Amazon Q responds with still indexing message even when `@workspace` index is done"
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import java.net.HttpURLConnection
import java.net.URL
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicInteger
import kotlin.time.Duration.Companion.minutes

class ProjectContextProvider(val project: Project, private val encoderServer: EncoderServer, private val cs: CoroutineScope) : Disposable {
private val retryCount = AtomicInteger(0)
Expand Down Expand Up @@ -218,9 +219,9 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
)
}

private fun setConnectionTimeout(connection: HttpURLConnection) {
connection.connectTimeout = 5000 // 5 seconds
connection.readTimeout = 5000 // 5 second
private fun setConnectionTimeout(connection: HttpURLConnection, timeout: Int) {
connection.connectTimeout = timeout
connection.readTimeout = timeout
}

private fun setConnectionProperties(connection: HttpURLConnection) {
Expand Down Expand Up @@ -311,10 +312,11 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
private fun sendMsgToLsp(msgType: LspMessage, request: String?): LspResponse {
logger.info { "sending message: ${msgType.endpoint} to lsp on port ${encoderServer.port}" }
val url = URL("http://localhost:${encoderServer.port}/${msgType.endpoint}")

// use 1h as timeout for index, 5 seconds for other APIs
val timeoutMs = if (msgType is LspMessage.Index) 60.minutes.inWholeMilliseconds.toInt() else 5000
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can/should these be enum?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timeoutMs can only be integer.

return with(url.openConnection() as HttpURLConnection) {
setConnectionProperties(this)
setConnectionTimeout(this)
setConnectionTimeout(this, timeoutMs)
request?.let { r ->
setConnectionRequest(this, r)
}
Expand Down
Loading