Skip to content

Commit 0011da9

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
1 parent 90620b6 commit 0011da9

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
@@ -171,6 +171,7 @@ export interface KernelTlsOptions {
171171
*/
172172
export interface KernelHttpOptions {
173173
customHeaders?: Array<{ name: string; value: string }>;
174+
socketTimeoutMs?: number;
174175
}
175176

176177
/**
@@ -392,7 +393,7 @@ function validateHeaderToken(kind: 'name' | 'value', headerName: string, token:
392393
}
393394

394395
export function buildKernelHttpOptions(options: ConnectionOptions): KernelHttpOptions {
395-
const { customHeaders, userAgentEntry } = options;
396+
const { customHeaders, userAgentEntry, socketTimeout } = options;
396397

397398
const headers: Array<{ name: string; value: string }> = [];
398399
if (customHeaders) {
@@ -414,7 +415,18 @@ export function buildKernelHttpOptions(options: ConnectionOptions): KernelHttpOp
414415
// Python connector's unconditional `base_headers` append.
415416
headers.push({ name: 'User-Agent', value: buildUserAgentString(userAgentEntry) });
416417

417-
return { customHeaders: headers };
418+
const http: KernelHttpOptions = { customHeaders: headers };
419+
// Per-connection socket read timeout (ms). The public `socketTimeout`
420+
// ConnectionOption maps onto the kernel napi `socketTimeoutMs`
421+
// (kernel `HttpConfig::request_timeout` / reqwest `Client::timeout`).
422+
// Only forward a POSITIVE value: `socketTimeout: 0` means "disabled / wait
423+
// indefinitely" on the Thrift path, but forwarding `0` would make reqwest
424+
// time out immediately, so we omit it and let the kernel keep its (large)
425+
// default — preserving the "effectively no idle timeout" semantics.
426+
if (typeof socketTimeout === 'number' && socketTimeout > 0) {
427+
http.socketTimeoutMs = socketTimeout;
428+
}
429+
return http;
418430
}
419431

420432
/**

0 commit comments

Comments
 (0)