rezo 1.0.11 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2502,8 +2502,73 @@ export interface RezoRequestConfig<D = any> {
2502
2502
  maxRedirects?: number;
2503
2503
  /** Whether to automatically decompress response data */
2504
2504
  decompress?: boolean;
2505
- /** Whether to keep the connection alive for reuse */
2505
+ /**
2506
+ * Whether to keep TCP connections alive for reuse across multiple requests.
2507
+ *
2508
+ * When enabled, the underlying TCP connection is kept open after a request completes,
2509
+ * allowing subsequent requests to the same host to reuse the connection. This reduces
2510
+ * latency by avoiding the overhead of establishing new connections (TCP handshake,
2511
+ * TLS negotiation for HTTPS).
2512
+ *
2513
+ * **Behavior:**
2514
+ * - `false` (default) - Connection closes after each request. Process exits immediately.
2515
+ * - `true` - Connection stays open for reuse. Idle connections close after `keepAliveMsecs`.
2516
+ *
2517
+ * **When to use `keepAlive: true`:**
2518
+ * - Making multiple requests to the same host in sequence
2519
+ * - Long-running applications (servers, bots, scrapers)
2520
+ * - Performance-critical applications where connection overhead matters
2521
+ *
2522
+ * **When to use `keepAlive: false` (default):**
2523
+ * - Single requests or scripts that should exit immediately
2524
+ * - CLI tools that make one-off requests
2525
+ * - When you need predictable process termination
2526
+ *
2527
+ * @example
2528
+ * ```typescript
2529
+ * // Default: process exits immediately after request
2530
+ * const { data } = await rezo.get('https://api.example.com/data');
2531
+ *
2532
+ * // Keep connection alive for 1 minute (default) for subsequent requests
2533
+ * const client = new Rezo({ keepAlive: true });
2534
+ * await client.get('https://api.example.com/users');
2535
+ * await client.get('https://api.example.com/posts'); // Reuses connection
2536
+ *
2537
+ * // Custom keep-alive timeout (30 seconds)
2538
+ * const client = new Rezo({ keepAlive: true, keepAliveMsecs: 30000 });
2539
+ * ```
2540
+ *
2541
+ * @default false
2542
+ */
2506
2543
  keepAlive?: boolean;
2544
+ /**
2545
+ * How long to keep idle connections alive in milliseconds.
2546
+ *
2547
+ * Only applies when `keepAlive: true`. After this duration of inactivity,
2548
+ * the connection is closed automatically. This prevents resource leaks
2549
+ * from connections that are no longer needed.
2550
+ *
2551
+ * **Note:** Even with keep-alive enabled, the Node.js process can still exit
2552
+ * cleanly when there's no other work to do, thanks to socket unreferencing.
2553
+ *
2554
+ * @example
2555
+ * ```typescript
2556
+ * // Keep connections alive for 30 seconds
2557
+ * const client = new Rezo({
2558
+ * keepAlive: true,
2559
+ * keepAliveMsecs: 30000
2560
+ * });
2561
+ *
2562
+ * // Keep connections alive for 2 minutes
2563
+ * const client = new Rezo({
2564
+ * keepAlive: true,
2565
+ * keepAliveMsecs: 120000
2566
+ * });
2567
+ * ```
2568
+ *
2569
+ * @default 60000 (1 minute)
2570
+ */
2571
+ keepAliveMsecs?: number;
2507
2572
  withoutBodyOnRedirect?: boolean;
2508
2573
  autoSetReferer?: boolean;
2509
2574
  autoSetOrigin?: boolean;
@@ -2502,8 +2502,73 @@ export interface RezoRequestConfig<D = any> {
2502
2502
  maxRedirects?: number;
2503
2503
  /** Whether to automatically decompress response data */
2504
2504
  decompress?: boolean;
2505
- /** Whether to keep the connection alive for reuse */
2505
+ /**
2506
+ * Whether to keep TCP connections alive for reuse across multiple requests.
2507
+ *
2508
+ * When enabled, the underlying TCP connection is kept open after a request completes,
2509
+ * allowing subsequent requests to the same host to reuse the connection. This reduces
2510
+ * latency by avoiding the overhead of establishing new connections (TCP handshake,
2511
+ * TLS negotiation for HTTPS).
2512
+ *
2513
+ * **Behavior:**
2514
+ * - `false` (default) - Connection closes after each request. Process exits immediately.
2515
+ * - `true` - Connection stays open for reuse. Idle connections close after `keepAliveMsecs`.
2516
+ *
2517
+ * **When to use `keepAlive: true`:**
2518
+ * - Making multiple requests to the same host in sequence
2519
+ * - Long-running applications (servers, bots, scrapers)
2520
+ * - Performance-critical applications where connection overhead matters
2521
+ *
2522
+ * **When to use `keepAlive: false` (default):**
2523
+ * - Single requests or scripts that should exit immediately
2524
+ * - CLI tools that make one-off requests
2525
+ * - When you need predictable process termination
2526
+ *
2527
+ * @example
2528
+ * ```typescript
2529
+ * // Default: process exits immediately after request
2530
+ * const { data } = await rezo.get('https://api.example.com/data');
2531
+ *
2532
+ * // Keep connection alive for 1 minute (default) for subsequent requests
2533
+ * const client = new Rezo({ keepAlive: true });
2534
+ * await client.get('https://api.example.com/users');
2535
+ * await client.get('https://api.example.com/posts'); // Reuses connection
2536
+ *
2537
+ * // Custom keep-alive timeout (30 seconds)
2538
+ * const client = new Rezo({ keepAlive: true, keepAliveMsecs: 30000 });
2539
+ * ```
2540
+ *
2541
+ * @default false
2542
+ */
2506
2543
  keepAlive?: boolean;
2544
+ /**
2545
+ * How long to keep idle connections alive in milliseconds.
2546
+ *
2547
+ * Only applies when `keepAlive: true`. After this duration of inactivity,
2548
+ * the connection is closed automatically. This prevents resource leaks
2549
+ * from connections that are no longer needed.
2550
+ *
2551
+ * **Note:** Even with keep-alive enabled, the Node.js process can still exit
2552
+ * cleanly when there's no other work to do, thanks to socket unreferencing.
2553
+ *
2554
+ * @example
2555
+ * ```typescript
2556
+ * // Keep connections alive for 30 seconds
2557
+ * const client = new Rezo({
2558
+ * keepAlive: true,
2559
+ * keepAliveMsecs: 30000
2560
+ * });
2561
+ *
2562
+ * // Keep connections alive for 2 minutes
2563
+ * const client = new Rezo({
2564
+ * keepAlive: true,
2565
+ * keepAliveMsecs: 120000
2566
+ * });
2567
+ * ```
2568
+ *
2569
+ * @default 60000 (1 minute)
2570
+ */
2571
+ keepAliveMsecs?: number;
2507
2572
  withoutBodyOnRedirect?: boolean;
2508
2573
  autoSetReferer?: boolean;
2509
2574
  autoSetOrigin?: boolean;
@@ -2502,8 +2502,73 @@ export interface RezoRequestConfig<D = any> {
2502
2502
  maxRedirects?: number;
2503
2503
  /** Whether to automatically decompress response data */
2504
2504
  decompress?: boolean;
2505
- /** Whether to keep the connection alive for reuse */
2505
+ /**
2506
+ * Whether to keep TCP connections alive for reuse across multiple requests.
2507
+ *
2508
+ * When enabled, the underlying TCP connection is kept open after a request completes,
2509
+ * allowing subsequent requests to the same host to reuse the connection. This reduces
2510
+ * latency by avoiding the overhead of establishing new connections (TCP handshake,
2511
+ * TLS negotiation for HTTPS).
2512
+ *
2513
+ * **Behavior:**
2514
+ * - `false` (default) - Connection closes after each request. Process exits immediately.
2515
+ * - `true` - Connection stays open for reuse. Idle connections close after `keepAliveMsecs`.
2516
+ *
2517
+ * **When to use `keepAlive: true`:**
2518
+ * - Making multiple requests to the same host in sequence
2519
+ * - Long-running applications (servers, bots, scrapers)
2520
+ * - Performance-critical applications where connection overhead matters
2521
+ *
2522
+ * **When to use `keepAlive: false` (default):**
2523
+ * - Single requests or scripts that should exit immediately
2524
+ * - CLI tools that make one-off requests
2525
+ * - When you need predictable process termination
2526
+ *
2527
+ * @example
2528
+ * ```typescript
2529
+ * // Default: process exits immediately after request
2530
+ * const { data } = await rezo.get('https://api.example.com/data');
2531
+ *
2532
+ * // Keep connection alive for 1 minute (default) for subsequent requests
2533
+ * const client = new Rezo({ keepAlive: true });
2534
+ * await client.get('https://api.example.com/users');
2535
+ * await client.get('https://api.example.com/posts'); // Reuses connection
2536
+ *
2537
+ * // Custom keep-alive timeout (30 seconds)
2538
+ * const client = new Rezo({ keepAlive: true, keepAliveMsecs: 30000 });
2539
+ * ```
2540
+ *
2541
+ * @default false
2542
+ */
2506
2543
  keepAlive?: boolean;
2544
+ /**
2545
+ * How long to keep idle connections alive in milliseconds.
2546
+ *
2547
+ * Only applies when `keepAlive: true`. After this duration of inactivity,
2548
+ * the connection is closed automatically. This prevents resource leaks
2549
+ * from connections that are no longer needed.
2550
+ *
2551
+ * **Note:** Even with keep-alive enabled, the Node.js process can still exit
2552
+ * cleanly when there's no other work to do, thanks to socket unreferencing.
2553
+ *
2554
+ * @example
2555
+ * ```typescript
2556
+ * // Keep connections alive for 30 seconds
2557
+ * const client = new Rezo({
2558
+ * keepAlive: true,
2559
+ * keepAliveMsecs: 30000
2560
+ * });
2561
+ *
2562
+ * // Keep connections alive for 2 minutes
2563
+ * const client = new Rezo({
2564
+ * keepAlive: true,
2565
+ * keepAliveMsecs: 120000
2566
+ * });
2567
+ * ```
2568
+ *
2569
+ * @default 60000 (1 minute)
2570
+ */
2571
+ keepAliveMsecs?: number;
2507
2572
  withoutBodyOnRedirect?: boolean;
2508
2573
  autoSetReferer?: boolean;
2509
2574
  autoSetOrigin?: boolean;
@@ -2502,8 +2502,73 @@ export interface RezoRequestConfig<D = any> {
2502
2502
  maxRedirects?: number;
2503
2503
  /** Whether to automatically decompress response data */
2504
2504
  decompress?: boolean;
2505
- /** Whether to keep the connection alive for reuse */
2505
+ /**
2506
+ * Whether to keep TCP connections alive for reuse across multiple requests.
2507
+ *
2508
+ * When enabled, the underlying TCP connection is kept open after a request completes,
2509
+ * allowing subsequent requests to the same host to reuse the connection. This reduces
2510
+ * latency by avoiding the overhead of establishing new connections (TCP handshake,
2511
+ * TLS negotiation for HTTPS).
2512
+ *
2513
+ * **Behavior:**
2514
+ * - `false` (default) - Connection closes after each request. Process exits immediately.
2515
+ * - `true` - Connection stays open for reuse. Idle connections close after `keepAliveMsecs`.
2516
+ *
2517
+ * **When to use `keepAlive: true`:**
2518
+ * - Making multiple requests to the same host in sequence
2519
+ * - Long-running applications (servers, bots, scrapers)
2520
+ * - Performance-critical applications where connection overhead matters
2521
+ *
2522
+ * **When to use `keepAlive: false` (default):**
2523
+ * - Single requests or scripts that should exit immediately
2524
+ * - CLI tools that make one-off requests
2525
+ * - When you need predictable process termination
2526
+ *
2527
+ * @example
2528
+ * ```typescript
2529
+ * // Default: process exits immediately after request
2530
+ * const { data } = await rezo.get('https://api.example.com/data');
2531
+ *
2532
+ * // Keep connection alive for 1 minute (default) for subsequent requests
2533
+ * const client = new Rezo({ keepAlive: true });
2534
+ * await client.get('https://api.example.com/users');
2535
+ * await client.get('https://api.example.com/posts'); // Reuses connection
2536
+ *
2537
+ * // Custom keep-alive timeout (30 seconds)
2538
+ * const client = new Rezo({ keepAlive: true, keepAliveMsecs: 30000 });
2539
+ * ```
2540
+ *
2541
+ * @default false
2542
+ */
2506
2543
  keepAlive?: boolean;
2544
+ /**
2545
+ * How long to keep idle connections alive in milliseconds.
2546
+ *
2547
+ * Only applies when `keepAlive: true`. After this duration of inactivity,
2548
+ * the connection is closed automatically. This prevents resource leaks
2549
+ * from connections that are no longer needed.
2550
+ *
2551
+ * **Note:** Even with keep-alive enabled, the Node.js process can still exit
2552
+ * cleanly when there's no other work to do, thanks to socket unreferencing.
2553
+ *
2554
+ * @example
2555
+ * ```typescript
2556
+ * // Keep connections alive for 30 seconds
2557
+ * const client = new Rezo({
2558
+ * keepAlive: true,
2559
+ * keepAliveMsecs: 30000
2560
+ * });
2561
+ *
2562
+ * // Keep connections alive for 2 minutes
2563
+ * const client = new Rezo({
2564
+ * keepAlive: true,
2565
+ * keepAliveMsecs: 120000
2566
+ * });
2567
+ * ```
2568
+ *
2569
+ * @default 60000 (1 minute)
2570
+ */
2571
+ keepAliveMsecs?: number;
2507
2572
  withoutBodyOnRedirect?: boolean;
2508
2573
  autoSetReferer?: boolean;
2509
2574
  autoSetOrigin?: boolean;
@@ -2502,8 +2502,73 @@ export interface RezoRequestConfig<D = any> {
2502
2502
  maxRedirects?: number;
2503
2503
  /** Whether to automatically decompress response data */
2504
2504
  decompress?: boolean;
2505
- /** Whether to keep the connection alive for reuse */
2505
+ /**
2506
+ * Whether to keep TCP connections alive for reuse across multiple requests.
2507
+ *
2508
+ * When enabled, the underlying TCP connection is kept open after a request completes,
2509
+ * allowing subsequent requests to the same host to reuse the connection. This reduces
2510
+ * latency by avoiding the overhead of establishing new connections (TCP handshake,
2511
+ * TLS negotiation for HTTPS).
2512
+ *
2513
+ * **Behavior:**
2514
+ * - `false` (default) - Connection closes after each request. Process exits immediately.
2515
+ * - `true` - Connection stays open for reuse. Idle connections close after `keepAliveMsecs`.
2516
+ *
2517
+ * **When to use `keepAlive: true`:**
2518
+ * - Making multiple requests to the same host in sequence
2519
+ * - Long-running applications (servers, bots, scrapers)
2520
+ * - Performance-critical applications where connection overhead matters
2521
+ *
2522
+ * **When to use `keepAlive: false` (default):**
2523
+ * - Single requests or scripts that should exit immediately
2524
+ * - CLI tools that make one-off requests
2525
+ * - When you need predictable process termination
2526
+ *
2527
+ * @example
2528
+ * ```typescript
2529
+ * // Default: process exits immediately after request
2530
+ * const { data } = await rezo.get('https://api.example.com/data');
2531
+ *
2532
+ * // Keep connection alive for 1 minute (default) for subsequent requests
2533
+ * const client = new Rezo({ keepAlive: true });
2534
+ * await client.get('https://api.example.com/users');
2535
+ * await client.get('https://api.example.com/posts'); // Reuses connection
2536
+ *
2537
+ * // Custom keep-alive timeout (30 seconds)
2538
+ * const client = new Rezo({ keepAlive: true, keepAliveMsecs: 30000 });
2539
+ * ```
2540
+ *
2541
+ * @default false
2542
+ */
2506
2543
  keepAlive?: boolean;
2544
+ /**
2545
+ * How long to keep idle connections alive in milliseconds.
2546
+ *
2547
+ * Only applies when `keepAlive: true`. After this duration of inactivity,
2548
+ * the connection is closed automatically. This prevents resource leaks
2549
+ * from connections that are no longer needed.
2550
+ *
2551
+ * **Note:** Even with keep-alive enabled, the Node.js process can still exit
2552
+ * cleanly when there's no other work to do, thanks to socket unreferencing.
2553
+ *
2554
+ * @example
2555
+ * ```typescript
2556
+ * // Keep connections alive for 30 seconds
2557
+ * const client = new Rezo({
2558
+ * keepAlive: true,
2559
+ * keepAliveMsecs: 30000
2560
+ * });
2561
+ *
2562
+ * // Keep connections alive for 2 minutes
2563
+ * const client = new Rezo({
2564
+ * keepAlive: true,
2565
+ * keepAliveMsecs: 120000
2566
+ * });
2567
+ * ```
2568
+ *
2569
+ * @default 60000 (1 minute)
2570
+ */
2571
+ keepAliveMsecs?: number;
2507
2572
  withoutBodyOnRedirect?: boolean;
2508
2573
  autoSetReferer?: boolean;
2509
2574
  autoSetOrigin?: boolean;
@@ -2502,8 +2502,73 @@ export interface RezoRequestConfig<D = any> {
2502
2502
  maxRedirects?: number;
2503
2503
  /** Whether to automatically decompress response data */
2504
2504
  decompress?: boolean;
2505
- /** Whether to keep the connection alive for reuse */
2505
+ /**
2506
+ * Whether to keep TCP connections alive for reuse across multiple requests.
2507
+ *
2508
+ * When enabled, the underlying TCP connection is kept open after a request completes,
2509
+ * allowing subsequent requests to the same host to reuse the connection. This reduces
2510
+ * latency by avoiding the overhead of establishing new connections (TCP handshake,
2511
+ * TLS negotiation for HTTPS).
2512
+ *
2513
+ * **Behavior:**
2514
+ * - `false` (default) - Connection closes after each request. Process exits immediately.
2515
+ * - `true` - Connection stays open for reuse. Idle connections close after `keepAliveMsecs`.
2516
+ *
2517
+ * **When to use `keepAlive: true`:**
2518
+ * - Making multiple requests to the same host in sequence
2519
+ * - Long-running applications (servers, bots, scrapers)
2520
+ * - Performance-critical applications where connection overhead matters
2521
+ *
2522
+ * **When to use `keepAlive: false` (default):**
2523
+ * - Single requests or scripts that should exit immediately
2524
+ * - CLI tools that make one-off requests
2525
+ * - When you need predictable process termination
2526
+ *
2527
+ * @example
2528
+ * ```typescript
2529
+ * // Default: process exits immediately after request
2530
+ * const { data } = await rezo.get('https://api.example.com/data');
2531
+ *
2532
+ * // Keep connection alive for 1 minute (default) for subsequent requests
2533
+ * const client = new Rezo({ keepAlive: true });
2534
+ * await client.get('https://api.example.com/users');
2535
+ * await client.get('https://api.example.com/posts'); // Reuses connection
2536
+ *
2537
+ * // Custom keep-alive timeout (30 seconds)
2538
+ * const client = new Rezo({ keepAlive: true, keepAliveMsecs: 30000 });
2539
+ * ```
2540
+ *
2541
+ * @default false
2542
+ */
2506
2543
  keepAlive?: boolean;
2544
+ /**
2545
+ * How long to keep idle connections alive in milliseconds.
2546
+ *
2547
+ * Only applies when `keepAlive: true`. After this duration of inactivity,
2548
+ * the connection is closed automatically. This prevents resource leaks
2549
+ * from connections that are no longer needed.
2550
+ *
2551
+ * **Note:** Even with keep-alive enabled, the Node.js process can still exit
2552
+ * cleanly when there's no other work to do, thanks to socket unreferencing.
2553
+ *
2554
+ * @example
2555
+ * ```typescript
2556
+ * // Keep connections alive for 30 seconds
2557
+ * const client = new Rezo({
2558
+ * keepAlive: true,
2559
+ * keepAliveMsecs: 30000
2560
+ * });
2561
+ *
2562
+ * // Keep connections alive for 2 minutes
2563
+ * const client = new Rezo({
2564
+ * keepAlive: true,
2565
+ * keepAliveMsecs: 120000
2566
+ * });
2567
+ * ```
2568
+ *
2569
+ * @default 60000 (1 minute)
2570
+ */
2571
+ keepAliveMsecs?: number;
2507
2572
  withoutBodyOnRedirect?: boolean;
2508
2573
  autoSetReferer?: boolean;
2509
2574
  autoSetOrigin?: boolean;
@@ -767,6 +767,9 @@ async function request(config, fetchOptions, requestCount, timing, _stats, respo
767
767
  }
768
768
  });
769
769
  req.on("socket", (socket) => {
770
+ if (socket && typeof socket.unref === "function") {
771
+ socket.unref();
772
+ }
770
773
  timing.dnsStart = performance.now();
771
774
  socket.on("lookup", () => {
772
775
  if (!config.timing.dnsMs) {
@@ -944,13 +947,16 @@ function buildHTTPOptions(fetchOptions, isSecure, url) {
944
947
  rejectUnauthorized,
945
948
  useSecureContext = true,
946
949
  auth,
947
- dnsCache: dnsCacheOption
950
+ dnsCache: dnsCacheOption,
951
+ keepAlive = false,
952
+ keepAliveMsecs = 60000
948
953
  } = fetchOptions;
949
954
  const secureContext = isSecure && useSecureContext ? new https.Agent({
950
955
  secureContext: createSecureContext(),
951
956
  servername: url.host,
952
957
  rejectUnauthorized,
953
- keepAlive: true
958
+ keepAlive,
959
+ keepAliveMsecs: keepAlive ? keepAliveMsecs : undefined
954
960
  }) : undefined;
955
961
  const customAgent = url.protocol === "https:" && httpsAgent ? httpsAgent : httpAgent ? httpAgent : undefined;
956
962
  const agent = parseProxy(proxy) || customAgent || secureContext;
@@ -767,6 +767,9 @@ async function request(config, fetchOptions, requestCount, timing, _stats, respo
767
767
  }
768
768
  });
769
769
  req.on("socket", (socket) => {
770
+ if (socket && typeof socket.unref === "function") {
771
+ socket.unref();
772
+ }
770
773
  timing.dnsStart = performance.now();
771
774
  socket.on("lookup", () => {
772
775
  if (!config.timing.dnsMs) {
@@ -944,13 +947,16 @@ function buildHTTPOptions(fetchOptions, isSecure, url) {
944
947
  rejectUnauthorized,
945
948
  useSecureContext = true,
946
949
  auth,
947
- dnsCache: dnsCacheOption
950
+ dnsCache: dnsCacheOption,
951
+ keepAlive = false,
952
+ keepAliveMsecs = 60000
948
953
  } = fetchOptions;
949
954
  const secureContext = isSecure && useSecureContext ? new https.Agent({
950
955
  secureContext: createSecureContext(),
951
956
  servername: url.host,
952
957
  rejectUnauthorized,
953
- keepAlive: true
958
+ keepAlive,
959
+ keepAliveMsecs: keepAlive ? keepAliveMsecs : undefined
954
960
  }) : undefined;
955
961
  const customAgent = url.protocol === "https:" && httpsAgent ? httpsAgent : httpAgent ? httpAgent : undefined;
956
962
  const agent = parseProxy(proxy) || customAgent || secureContext;
@@ -147,6 +147,10 @@ class Http2SessionPool {
147
147
  settled = true;
148
148
  if (timeoutId)
149
149
  clearTimeout(timeoutId);
150
+ const socket = session.socket;
151
+ if (socket && typeof socket.unref === "function") {
152
+ socket.unref();
153
+ }
150
154
  resolve(session);
151
155
  }
152
156
  });
@@ -147,6 +147,10 @@ class Http2SessionPool {
147
147
  settled = true;
148
148
  if (timeoutId)
149
149
  clearTimeout(timeoutId);
150
+ const socket = session.socket;
151
+ if (socket && typeof socket.unref === "function") {
152
+ socket.unref();
153
+ }
150
154
  resolve(session);
151
155
  }
152
156
  });
@@ -1,6 +1,6 @@
1
- const _mod_2r8qwe = require('./picker.cjs');
2
- exports.detectRuntime = _mod_2r8qwe.detectRuntime;
3
- exports.getAdapterCapabilities = _mod_2r8qwe.getAdapterCapabilities;
4
- exports.buildAdapterContext = _mod_2r8qwe.buildAdapterContext;
5
- exports.getAvailableAdapters = _mod_2r8qwe.getAvailableAdapters;
6
- exports.selectAdapter = _mod_2r8qwe.selectAdapter;;
1
+ const _mod_879ve5 = require('./picker.cjs');
2
+ exports.detectRuntime = _mod_879ve5.detectRuntime;
3
+ exports.getAdapterCapabilities = _mod_879ve5.getAdapterCapabilities;
4
+ exports.buildAdapterContext = _mod_879ve5.buildAdapterContext;
5
+ exports.getAvailableAdapters = _mod_879ve5.getAvailableAdapters;
6
+ exports.selectAdapter = _mod_879ve5.selectAdapter;;
@@ -1,13 +1,13 @@
1
- const _mod_n1lpkm = require('./lru-cache.cjs');
2
- exports.LRUCache = _mod_n1lpkm.LRUCache;;
3
- const _mod_iq5ukf = require('./dns-cache.cjs');
4
- exports.DNSCache = _mod_iq5ukf.DNSCache;
5
- exports.getGlobalDNSCache = _mod_iq5ukf.getGlobalDNSCache;
6
- exports.resetGlobalDNSCache = _mod_iq5ukf.resetGlobalDNSCache;;
7
- const _mod_f96z7x = require('./response-cache.cjs');
8
- exports.ResponseCache = _mod_f96z7x.ResponseCache;
9
- exports.normalizeResponseCacheConfig = _mod_f96z7x.normalizeResponseCacheConfig;;
10
- const _mod_j5l68j = require('./file-cacher.cjs');
11
- exports.FileCacher = _mod_j5l68j.FileCacher;;
12
- const _mod_2bqslo = require('./url-store.cjs');
13
- exports.UrlStore = _mod_2bqslo.UrlStore;;
1
+ const _mod_2rlcbw = require('./lru-cache.cjs');
2
+ exports.LRUCache = _mod_2rlcbw.LRUCache;;
3
+ const _mod_faep7r = require('./dns-cache.cjs');
4
+ exports.DNSCache = _mod_faep7r.DNSCache;
5
+ exports.getGlobalDNSCache = _mod_faep7r.getGlobalDNSCache;
6
+ exports.resetGlobalDNSCache = _mod_faep7r.resetGlobalDNSCache;;
7
+ const _mod_kp3skc = require('./response-cache.cjs');
8
+ exports.ResponseCache = _mod_kp3skc.ResponseCache;
9
+ exports.normalizeResponseCacheConfig = _mod_kp3skc.normalizeResponseCacheConfig;;
10
+ const _mod_dok148 = require('./file-cacher.cjs');
11
+ exports.FileCacher = _mod_dok148.FileCacher;;
12
+ const _mod_wzzzfr = require('./url-store.cjs');
13
+ exports.UrlStore = _mod_wzzzfr.UrlStore;;
package/dist/crawler.d.ts CHANGED
@@ -2620,8 +2620,73 @@ export interface RezoRequestConfig<D = any> {
2620
2620
  maxRedirects?: number;
2621
2621
  /** Whether to automatically decompress response data */
2622
2622
  decompress?: boolean;
2623
- /** Whether to keep the connection alive for reuse */
2623
+ /**
2624
+ * Whether to keep TCP connections alive for reuse across multiple requests.
2625
+ *
2626
+ * When enabled, the underlying TCP connection is kept open after a request completes,
2627
+ * allowing subsequent requests to the same host to reuse the connection. This reduces
2628
+ * latency by avoiding the overhead of establishing new connections (TCP handshake,
2629
+ * TLS negotiation for HTTPS).
2630
+ *
2631
+ * **Behavior:**
2632
+ * - `false` (default) - Connection closes after each request. Process exits immediately.
2633
+ * - `true` - Connection stays open for reuse. Idle connections close after `keepAliveMsecs`.
2634
+ *
2635
+ * **When to use `keepAlive: true`:**
2636
+ * - Making multiple requests to the same host in sequence
2637
+ * - Long-running applications (servers, bots, scrapers)
2638
+ * - Performance-critical applications where connection overhead matters
2639
+ *
2640
+ * **When to use `keepAlive: false` (default):**
2641
+ * - Single requests or scripts that should exit immediately
2642
+ * - CLI tools that make one-off requests
2643
+ * - When you need predictable process termination
2644
+ *
2645
+ * @example
2646
+ * ```typescript
2647
+ * // Default: process exits immediately after request
2648
+ * const { data } = await rezo.get('https://api.example.com/data');
2649
+ *
2650
+ * // Keep connection alive for 1 minute (default) for subsequent requests
2651
+ * const client = new Rezo({ keepAlive: true });
2652
+ * await client.get('https://api.example.com/users');
2653
+ * await client.get('https://api.example.com/posts'); // Reuses connection
2654
+ *
2655
+ * // Custom keep-alive timeout (30 seconds)
2656
+ * const client = new Rezo({ keepAlive: true, keepAliveMsecs: 30000 });
2657
+ * ```
2658
+ *
2659
+ * @default false
2660
+ */
2624
2661
  keepAlive?: boolean;
2662
+ /**
2663
+ * How long to keep idle connections alive in milliseconds.
2664
+ *
2665
+ * Only applies when `keepAlive: true`. After this duration of inactivity,
2666
+ * the connection is closed automatically. This prevents resource leaks
2667
+ * from connections that are no longer needed.
2668
+ *
2669
+ * **Note:** Even with keep-alive enabled, the Node.js process can still exit
2670
+ * cleanly when there's no other work to do, thanks to socket unreferencing.
2671
+ *
2672
+ * @example
2673
+ * ```typescript
2674
+ * // Keep connections alive for 30 seconds
2675
+ * const client = new Rezo({
2676
+ * keepAlive: true,
2677
+ * keepAliveMsecs: 30000
2678
+ * });
2679
+ *
2680
+ * // Keep connections alive for 2 minutes
2681
+ * const client = new Rezo({
2682
+ * keepAlive: true,
2683
+ * keepAliveMsecs: 120000
2684
+ * });
2685
+ * ```
2686
+ *
2687
+ * @default 60000 (1 minute)
2688
+ */
2689
+ keepAliveMsecs?: number;
2625
2690
  withoutBodyOnRedirect?: boolean;
2626
2691
  autoSetReferer?: boolean;
2627
2692
  autoSetOrigin?: boolean;
@@ -1,5 +1,5 @@
1
- const _mod_260i4j = require('../plugin/crawler.cjs');
2
- exports.Crawler = _mod_260i4j.Crawler;;
3
- const _mod_laig8l = require('../plugin/crawler-options.cjs');
4
- exports.CrawlerOptions = _mod_laig8l.CrawlerOptions;
5
- exports.Domain = _mod_laig8l.Domain;;
1
+ const _mod_rnh6oq = require('../plugin/crawler.cjs');
2
+ exports.Crawler = _mod_rnh6oq.Crawler;;
3
+ const _mod_7z7l7f = require('../plugin/crawler-options.cjs');
4
+ exports.CrawlerOptions = _mod_7z7l7f.CrawlerOptions;
5
+ exports.Domain = _mod_7z7l7f.Domain;;