Unreachable container times out gracefully
This commit is contained in:
@@ -25,8 +25,8 @@ ENV JAVA_HOME="/usr/lib/jvm/java-17-openjdk"
|
|||||||
# Eclipse JDT Language Server — canonical LSP for Java/JVM (Java, Kotlin, Groovy).
|
# Eclipse JDT Language Server — canonical LSP for Java/JVM (Java, Kotlin, Groovy).
|
||||||
# Pin to a specific release; update JDTLS_VERSION + JDTLS_BUILD for upgrades.
|
# Pin to a specific release; update JDTLS_VERSION + JDTLS_BUILD for upgrades.
|
||||||
# All releases: https://github.com/eclipse-jdtls/eclipse.jdt.ls/releases
|
# All releases: https://github.com/eclipse-jdtls/eclipse.jdt.ls/releases
|
||||||
ENV JDTLS_VERSION="1.38.0" \
|
ENV JDTLS_VERSION="1.60.0" \
|
||||||
JDTLS_BUILD="202503271418"
|
JDTLS_BUILD="202606262232"
|
||||||
RUN mkdir -p /opt/jdtls \
|
RUN mkdir -p /opt/jdtls \
|
||||||
&& curl -fsSL \
|
&& curl -fsSL \
|
||||||
"https://download.eclipse.org/jdtls/milestones/${JDTLS_VERSION}/jdt-language-server-${JDTLS_VERSION}-${JDTLS_BUILD}.tar.gz" \
|
"https://download.eclipse.org/jdtls/milestones/${JDTLS_VERSION}/jdt-language-server-${JDTLS_VERSION}-${JDTLS_BUILD}.tar.gz" \
|
||||||
|
|||||||
@@ -183,13 +183,24 @@ impl BotContext {
|
|||||||
Err(e) => return Some(format!("Failed to serialize RPC request: {e}")),
|
Err(e) => return Some(format!("Failed to serialize RPC request: {e}")),
|
||||||
};
|
};
|
||||||
|
|
||||||
let ws_stream = match tokio_tungstenite::connect_async(&ws_url).await {
|
let connect_timeout = std::time::Duration::from_secs(5);
|
||||||
Ok((stream, _)) => stream,
|
let ws_stream = match tokio::time::timeout(
|
||||||
Err(e) => {
|
connect_timeout,
|
||||||
|
tokio_tungstenite::connect_async(&ws_url),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(Ok((stream, _))) => stream,
|
||||||
|
Ok(Err(e)) => {
|
||||||
return Some(format!(
|
return Some(format!(
|
||||||
"Failed to connect to project server at {ws_url}: {e}"
|
"Failed to connect to project server at {ws_url}: {e}"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
Err(_) => {
|
||||||
|
return Some(format!(
|
||||||
|
"Project server at {ws_url} is unreachable (connect timed out after {connect_timeout:?})"
|
||||||
|
));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let (mut sink, mut stream) = ws_stream.split();
|
let (mut sink, mut stream) = ws_stream.split();
|
||||||
@@ -198,7 +209,9 @@ impl BotContext {
|
|||||||
return Some(format!("Failed to send RPC request: {e}"));
|
return Some(format!("Failed to send RPC request: {e}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
while let Some(msg) = stream.next().await {
|
let response_timeout = std::time::Duration::from_secs(30);
|
||||||
|
let deadline = tokio::time::Instant::now() + response_timeout;
|
||||||
|
while let Ok(Some(msg)) = tokio::time::timeout_at(deadline, stream.next()).await {
|
||||||
match msg {
|
match msg {
|
||||||
Ok(WsMsg::Text(text)) => {
|
Ok(WsMsg::Text(text)) => {
|
||||||
let Ok(frame) = serde_json::from_str::<serde_json::Value>(&text) else {
|
let Ok(frame) = serde_json::from_str::<serde_json::Value>(&text) else {
|
||||||
@@ -239,7 +252,7 @@ impl BotContext {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Some("Connection closed before receiving command response".to_string())
|
Some("Project server did not respond in time (connection closed or timed out)".to_string())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user