Skip to content

Commit 8e1a5de

Browse files
committed
properly handle connection refused
1 parent 3357e88 commit 8e1a5de

File tree

1 file changed

+11
-3
lines changed
  • plugins/amazonq/shared/jetbrains-community/src/software/aws/toolkits/jetbrains/services/amazonq/project

1 file changed

+11
-3
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,19 @@ class ProjectContextProvider(val project: Project, private val encoderServer: En
123123
}
124124
retryCount.incrementAndGet()
125125
} catch (e: Exception) {
126-
logger.warn(e) { "failed to init project context" }
127126
if (e.stackTraceToString().contains("Connection refused")) {
128-
retryCount.incrementAndGet()
129-
delay(10000)
127+
if (encoderServer.isNodeProcessRunning()) {
128+
// there is a chance that client throws java.net.ConnectException: Connection refused
129+
// in this case, the server is busy doing tree sitter parsing
130+
// and will be responsive later once it goes past the tree sitter parsing phrase.
131+
// Long term solution is to move encode server to LSP protocol
132+
return
133+
} else {
134+
retryCount.incrementAndGet()
135+
delay(10000)
136+
}
130137
} else {
138+
logger.warn(e) { "failed to init project context" }
131139
return
132140
}
133141
}

0 commit comments

Comments
 (0)