rezo 1.0.10 → 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.
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;
@@ -4219,6 +4284,7 @@ declare class Rezo {
4219
4284
  private __create;
4220
4285
  /** Get the cookie jar for this instance */
4221
4286
  get cookieJar(): RezoCookieJar;
4287
+ set cookieJar(jar: RezoCookieJar);
4222
4288
  /**
4223
4289
  * Save cookies to file (if cookieFile is configured).
4224
4290
  * Can also specify a different path to save to.
@@ -1,5 +1,5 @@
1
- const _mod_f905u8 = require('../plugin/crawler.cjs');
2
- exports.Crawler = _mod_f905u8.Crawler;;
3
- const _mod_885b6l = require('../plugin/crawler-options.cjs');
4
- exports.CrawlerOptions = _mod_885b6l.CrawlerOptions;
5
- exports.Domain = _mod_885b6l.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;;
package/dist/index.cjs CHANGED
@@ -1,27 +1,27 @@
1
- const _mod_3dvs8m = require('./core/rezo.cjs');
2
- exports.Rezo = _mod_3dvs8m.Rezo;
3
- exports.createRezoInstance = _mod_3dvs8m.createRezoInstance;
4
- exports.createDefaultInstance = _mod_3dvs8m.createDefaultInstance;;
5
- const _mod_r7o6q6 = require('./errors/rezo-error.cjs');
6
- exports.RezoError = _mod_r7o6q6.RezoError;
7
- exports.RezoErrorCode = _mod_r7o6q6.RezoErrorCode;;
8
- const _mod_6y2l73 = require('./utils/headers.cjs');
9
- exports.RezoHeaders = _mod_6y2l73.RezoHeaders;;
10
- const _mod_5033qo = require('./utils/form-data.cjs');
11
- exports.RezoFormData = _mod_5033qo.RezoFormData;;
12
- const _mod_wvl5qh = require('./utils/cookies.cjs');
13
- exports.RezoCookieJar = _mod_wvl5qh.RezoCookieJar;
14
- exports.Cookie = _mod_wvl5qh.Cookie;;
15
- const _mod_gqvwg5 = require('./core/hooks.cjs');
16
- exports.createDefaultHooks = _mod_gqvwg5.createDefaultHooks;
17
- exports.mergeHooks = _mod_gqvwg5.mergeHooks;;
18
- const _mod_xy25q8 = require('./proxy/manager.cjs');
19
- exports.ProxyManager = _mod_xy25q8.ProxyManager;;
20
- const _mod_k77c7o = require('./queue/index.cjs');
21
- exports.RezoQueue = _mod_k77c7o.RezoQueue;
22
- exports.HttpQueue = _mod_k77c7o.HttpQueue;
23
- exports.Priority = _mod_k77c7o.Priority;
24
- exports.HttpMethodPriority = _mod_k77c7o.HttpMethodPriority;;
1
+ const _mod_jr843j = require('./core/rezo.cjs');
2
+ exports.Rezo = _mod_jr843j.Rezo;
3
+ exports.createRezoInstance = _mod_jr843j.createRezoInstance;
4
+ exports.createDefaultInstance = _mod_jr843j.createDefaultInstance;;
5
+ const _mod_tk44ak = require('./errors/rezo-error.cjs');
6
+ exports.RezoError = _mod_tk44ak.RezoError;
7
+ exports.RezoErrorCode = _mod_tk44ak.RezoErrorCode;;
8
+ const _mod_n1xwl0 = require('./utils/headers.cjs');
9
+ exports.RezoHeaders = _mod_n1xwl0.RezoHeaders;;
10
+ const _mod_ci344r = require('./utils/form-data.cjs');
11
+ exports.RezoFormData = _mod_ci344r.RezoFormData;;
12
+ const _mod_611jzw = require('./utils/cookies.cjs');
13
+ exports.RezoCookieJar = _mod_611jzw.RezoCookieJar;
14
+ exports.Cookie = _mod_611jzw.Cookie;;
15
+ const _mod_7h5jew = require('./core/hooks.cjs');
16
+ exports.createDefaultHooks = _mod_7h5jew.createDefaultHooks;
17
+ exports.mergeHooks = _mod_7h5jew.mergeHooks;;
18
+ const _mod_0rf8qu = require('./proxy/manager.cjs');
19
+ exports.ProxyManager = _mod_0rf8qu.ProxyManager;;
20
+ const _mod_ho3aaq = require('./queue/index.cjs');
21
+ exports.RezoQueue = _mod_ho3aaq.RezoQueue;
22
+ exports.HttpQueue = _mod_ho3aaq.HttpQueue;
23
+ exports.Priority = _mod_ho3aaq.Priority;
24
+ exports.HttpMethodPriority = _mod_ho3aaq.HttpMethodPriority;;
25
25
  const { RezoError } = require('./errors/rezo-error.cjs');
26
26
  const isRezoError = exports.isRezoError = RezoError.isRezoError;
27
27
  const Cancel = exports.Cancel = RezoError;
package/dist/index.d.ts CHANGED
@@ -2628,8 +2628,73 @@ export interface RezoRequestConfig<D = any> {
2628
2628
  maxRedirects?: number;
2629
2629
  /** Whether to automatically decompress response data */
2630
2630
  decompress?: boolean;
2631
- /** Whether to keep the connection alive for reuse */
2631
+ /**
2632
+ * Whether to keep TCP connections alive for reuse across multiple requests.
2633
+ *
2634
+ * When enabled, the underlying TCP connection is kept open after a request completes,
2635
+ * allowing subsequent requests to the same host to reuse the connection. This reduces
2636
+ * latency by avoiding the overhead of establishing new connections (TCP handshake,
2637
+ * TLS negotiation for HTTPS).
2638
+ *
2639
+ * **Behavior:**
2640
+ * - `false` (default) - Connection closes after each request. Process exits immediately.
2641
+ * - `true` - Connection stays open for reuse. Idle connections close after `keepAliveMsecs`.
2642
+ *
2643
+ * **When to use `keepAlive: true`:**
2644
+ * - Making multiple requests to the same host in sequence
2645
+ * - Long-running applications (servers, bots, scrapers)
2646
+ * - Performance-critical applications where connection overhead matters
2647
+ *
2648
+ * **When to use `keepAlive: false` (default):**
2649
+ * - Single requests or scripts that should exit immediately
2650
+ * - CLI tools that make one-off requests
2651
+ * - When you need predictable process termination
2652
+ *
2653
+ * @example
2654
+ * ```typescript
2655
+ * // Default: process exits immediately after request
2656
+ * const { data } = await rezo.get('https://api.example.com/data');
2657
+ *
2658
+ * // Keep connection alive for 1 minute (default) for subsequent requests
2659
+ * const client = new Rezo({ keepAlive: true });
2660
+ * await client.get('https://api.example.com/users');
2661
+ * await client.get('https://api.example.com/posts'); // Reuses connection
2662
+ *
2663
+ * // Custom keep-alive timeout (30 seconds)
2664
+ * const client = new Rezo({ keepAlive: true, keepAliveMsecs: 30000 });
2665
+ * ```
2666
+ *
2667
+ * @default false
2668
+ */
2632
2669
  keepAlive?: boolean;
2670
+ /**
2671
+ * How long to keep idle connections alive in milliseconds.
2672
+ *
2673
+ * Only applies when `keepAlive: true`. After this duration of inactivity,
2674
+ * the connection is closed automatically. This prevents resource leaks
2675
+ * from connections that are no longer needed.
2676
+ *
2677
+ * **Note:** Even with keep-alive enabled, the Node.js process can still exit
2678
+ * cleanly when there's no other work to do, thanks to socket unreferencing.
2679
+ *
2680
+ * @example
2681
+ * ```typescript
2682
+ * // Keep connections alive for 30 seconds
2683
+ * const client = new Rezo({
2684
+ * keepAlive: true,
2685
+ * keepAliveMsecs: 30000
2686
+ * });
2687
+ *
2688
+ * // Keep connections alive for 2 minutes
2689
+ * const client = new Rezo({
2690
+ * keepAlive: true,
2691
+ * keepAliveMsecs: 120000
2692
+ * });
2693
+ * ```
2694
+ *
2695
+ * @default 60000 (1 minute)
2696
+ */
2697
+ keepAliveMsecs?: number;
2633
2698
  withoutBodyOnRedirect?: boolean;
2634
2699
  autoSetReferer?: boolean;
2635
2700
  autoSetOrigin?: boolean;
@@ -4249,6 +4314,7 @@ export declare class Rezo {
4249
4314
  private __create;
4250
4315
  /** Get the cookie jar for this instance */
4251
4316
  get cookieJar(): RezoCookieJar;
4317
+ set cookieJar(jar: RezoCookieJar);
4252
4318
  /**
4253
4319
  * Save cookies to file (if cookieFile is configured).
4254
4320
  * Can also specify a different path to save to.
@@ -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;
@@ -4104,6 +4169,7 @@ export declare class Rezo {
4104
4169
  private __create;
4105
4170
  /** Get the cookie jar for this instance */
4106
4171
  get cookieJar(): RezoCookieJar;
4172
+ set cookieJar(jar: RezoCookieJar);
4107
4173
  /**
4108
4174
  * Save cookies to file (if cookieFile is configured).
4109
4175
  * Can also specify a different path to save to.
@@ -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;
@@ -4104,6 +4169,7 @@ export declare class Rezo {
4104
4169
  private __create;
4105
4170
  /** Get the cookie jar for this instance */
4106
4171
  get cookieJar(): RezoCookieJar;
4172
+ set cookieJar(jar: RezoCookieJar);
4107
4173
  /**
4108
4174
  * Save cookies to file (if cookieFile is configured).
4109
4175
  * Can also specify a different path to save to.
@@ -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;
@@ -4104,6 +4169,7 @@ export declare class Rezo {
4104
4169
  private __create;
4105
4170
  /** Get the cookie jar for this instance */
4106
4171
  get cookieJar(): RezoCookieJar;
4172
+ set cookieJar(jar: RezoCookieJar);
4107
4173
  /**
4108
4174
  * Save cookies to file (if cookieFile is configured).
4109
4175
  * Can also specify a different path to save to.
@@ -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;
@@ -4104,6 +4169,7 @@ export declare class Rezo {
4104
4169
  private __create;
4105
4170
  /** Get the cookie jar for this instance */
4106
4171
  get cookieJar(): RezoCookieJar;
4172
+ set cookieJar(jar: RezoCookieJar);
4107
4173
  /**
4108
4174
  * Save cookies to file (if cookieFile is configured).
4109
4175
  * Can also specify a different path to save to.
@@ -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;
@@ -4104,6 +4169,7 @@ export declare class Rezo {
4104
4169
  private __create;
4105
4170
  /** Get the cookie jar for this instance */
4106
4171
  get cookieJar(): RezoCookieJar;
4172
+ set cookieJar(jar: RezoCookieJar);
4107
4173
  /**
4108
4174
  * Save cookies to file (if cookieFile is configured).
4109
4175
  * Can also specify a different path to save to.