fix: keep pod log streams alive

This commit is contained in:
2026-09-27 11:37:02 +00:00 Unverified
parent 5f7509a9c5
commit d3e9753c4b
8 changed files with 32 additions and 9 deletions
+11 -2
View File
@@ -40,10 +40,19 @@ function logError(error: unknown): KubernetesLogError {
error && typeof error === "object" && "code" in error
? error.code
: undefined;
const transientNetworkCodes = new Set([
"ECONNRESET", "ETIMEDOUT", "EPIPE", "ECONNREFUSED", "EHOSTUNREACH",
"ENETUNREACH", "ECONNABORTED", "EAI_AGAIN", "UND_ERR_SOCKET",
"UND_ERR_CONNECT_TIMEOUT",
]);
const message = error instanceof Error ? error.message : "";
return new KubernetesLogError(
error instanceof Error ? error.message : "Kubernetes log request failed",
code === undefined &&
(status === undefined || status === 408 || status === 429 || status >= 500),
typeof code === "string"
? transientNetworkCodes.has(code)
: status === undefined && /socket hang up|socket closed/i.test(message)
? true
: status === undefined || status === 408 || status === 429 || status >= 500,
);
}
+6 -2
View File
@@ -438,7 +438,7 @@ export class LogService {
const discoveryInterval = positiveInteger(input.discoveryIntervalMs, 2_000);
const heartbeatInterval = positiveInteger(
input.heartbeatIntervalMs,
15_000,
5_000,
);
const retryInterval = positiveInteger(input.retryIntervalMs, 1_000);
const queue = new BoundedAsyncQueue<LogEvent>(capacity);
@@ -489,7 +489,11 @@ export class LogService {
signal,
(event) => queue.push(event),
);
if (!signal.aborted) completed.add(key);
if (!signal.aborted)
throw new KubernetesLogError(
"Kubernetes log stream ended unexpectedly",
true,
);
} catch (error) {
if (!isAbort(signal)) {
await pushError(error, source);