Skip to content

Commit 6e75e49

Browse files
committed
[SEA-NodeJS] feat(kernel): map the socketTimeout ConnectionOption onto the kernel
The kernel napi binding exposes `socketTimeoutMs` (kernel `HttpConfig::request_timeout` / reqwest `Client::timeout`, kernel #129). Map the public `socketTimeout` ConnectionOption (ms) onto it in `buildKernelHttpOptions`, so the per-connection read timeout works on the kernel backend just like the Thrift path. Only a positive value is forwarded: `socketTimeout: 0` means "disabled / wait indefinitely" on Thrift, but forwarding `0` would make reqwest time out immediately, so it is omitted (kernel keeps its large default). Verified directly against a live serverless warehouse: `socketTimeout: 1` makes a SEA request time out. Co-authored-by: Isaac Signed-off-by: Madhavendra Rathore <madhavendra.rathore@databricks.com>
1 parent d94d57a commit 6e75e49

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

lib/kernel/KernelAuth.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ export interface KernelTlsOptions {
190190
*/
191191
export interface KernelHttpOptions {
192192
customHeaders?: Array<{ name: string; value: string }>;
193+
socketTimeoutMs?: number;
193194
}
194195

195196
/**
@@ -414,7 +415,7 @@ function validateHeaderToken(kind: 'name' | 'value', headerName: string, token:
414415
}
415416

416417
export function buildKernelHttpOptions(options: ConnectionOptions): KernelHttpOptions {
417-
const { customHeaders, userAgentEntry } = options;
418+
const { customHeaders, userAgentEntry, socketTimeout } = options;
418419

419420
const headers: Array<{ name: string; value: string }> = [];
420421
if (customHeaders) {
@@ -436,7 +437,18 @@ export function buildKernelHttpOptions(options: ConnectionOptions): KernelHttpOp
436437
// Python connector's unconditional `base_headers` append.
437438
headers.push({ name: 'User-Agent', value: buildUserAgentString(userAgentEntry) });
438439

439-
return { customHeaders: headers };
440+
const http: KernelHttpOptions = { customHeaders: headers };
441+
// Per-connection socket read timeout (ms). The public `socketTimeout`
442+
// ConnectionOption maps onto the kernel napi `socketTimeoutMs`
443+
// (kernel `HttpConfig::request_timeout` / reqwest `Client::timeout`).
444+
// Only forward a POSITIVE value: `socketTimeout: 0` means "disabled / wait
445+
// indefinitely" on the Thrift path, but forwarding `0` would make reqwest
446+
// time out immediately, so we omit it and let the kernel keep its (large)
447+
// default — preserving the "effectively no idle timeout" semantics.
448+
if (typeof socketTimeout === 'number' && socketTimeout > 0) {
449+
http.socketTimeoutMs = socketTimeout;
450+
}
451+
return http;
440452
}
441453

442454
/**

0 commit comments

Comments
 (0)