fix(cassandra): shorten the read timeout below the rpc deadline (#2198)

This commit is contained in:
Hampus
2026-08-31 00:06:29 +02:00
committed by GitHub
parent b5496097d2
commit f1400ae58e
4 changed files with 18 additions and 4 deletions
+8 -2
View File
@@ -7,7 +7,10 @@ import cassandra from 'cassandra-driver';
const distance = cassandra.types.distance;
const MAX_REQUESTS_PER_CONNECTION = 2048;
const READ_TIMEOUT_MS = 12000;
const CONNECT_TIMEOUT_MS = 5000;
const DEFAULT_READ_TIMEOUT_MS = 5000;
export const BACKGROUND_READ_TIMEOUT_MS = 12000;
interface CassandraConfig {
hosts: Array<string>;
@@ -16,6 +19,7 @@ interface CassandraConfig {
localDc: string;
username?: string | undefined;
password?: string | undefined;
readTimeoutMs?: number | undefined;
}
interface CassandraClientOptions {
@@ -66,6 +70,7 @@ class CassandraClient implements ICassandraClient {
localDc: config.localDc,
username: config.username,
password: config.password,
readTimeoutMs: config.readTimeoutMs,
};
this.logger = options.logger ?? NoopLogger;
this.client = null;
@@ -93,7 +98,8 @@ class CassandraClient implements ICassandraClient {
},
},
socketOptions: {
readTimeout: READ_TIMEOUT_MS,
connectTimeout: CONNECT_TIMEOUT_MS,
readTimeout: this.config.readTimeoutMs ?? DEFAULT_READ_TIMEOUT_MS,
},
encoding: {
map: Map,