@types/node 24.3.0 → 24.7.2

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.
node/http.d.ts CHANGED
@@ -200,7 +200,7 @@ declare module "http" {
200
200
  "x-frame-options"?: string | undefined;
201
201
  "x-xss-protection"?: string | undefined;
202
202
  }
203
- interface ClientRequestArgs {
203
+ interface ClientRequestArgs extends Pick<LookupOptions, "hints"> {
204
204
  _defaultAgent?: Agent | undefined;
205
205
  agent?: Agent | boolean | undefined;
206
206
  auth?: string | null | undefined;
@@ -213,7 +213,6 @@ declare module "http" {
213
213
  defaultPort?: number | string | undefined;
214
214
  family?: number | undefined;
215
215
  headers?: OutgoingHttpHeaders | readonly string[] | undefined;
216
- hints?: LookupOptions["hints"];
217
216
  host?: string | null | undefined;
218
217
  hostname?: string | null | undefined;
219
218
  insecureHTTPParser?: boolean | undefined;
@@ -234,7 +233,7 @@ declare module "http" {
234
233
  socketPath?: string | undefined;
235
234
  timeout?: number | undefined;
236
235
  uniqueHeaders?: Array<string | string[]> | undefined;
237
- joinDuplicateHeaders?: boolean;
236
+ joinDuplicateHeaders?: boolean | undefined;
238
237
  }
239
238
  interface ServerOptions<
240
239
  Request extends typeof IncomingMessage = typeof IncomingMessage,
@@ -260,7 +259,7 @@ declare module "http" {
260
259
  * @default false
261
260
  * @since v18.14.0
262
261
  */
263
- joinDuplicateHeaders?: boolean;
262
+ joinDuplicateHeaders?: boolean | undefined;
264
263
  /**
265
264
  * The number of milliseconds of inactivity a server needs to wait for additional incoming data,
266
265
  * after it has finished writing the last response, before a socket will be destroyed.
@@ -269,6 +268,13 @@ declare module "http" {
269
268
  * @since v18.0.0
270
269
  */
271
270
  keepAliveTimeout?: number | undefined;
271
+ /**
272
+ * An additional buffer time added to the
273
+ * `server.keepAliveTimeout` to extend the internal socket timeout.
274
+ * @since 24.6.0
275
+ * @default 1000
276
+ */
277
+ keepAliveTimeoutBuffer?: number | undefined;
272
278
  /**
273
279
  * Sets the interval value in milliseconds to check for request and headers timeout in incomplete requests.
274
280
  * @default 30000
@@ -413,12 +419,18 @@ declare module "http" {
413
419
  /**
414
420
  * The number of milliseconds of inactivity a server needs to wait for additional
415
421
  * incoming data, after it has finished writing the last response, before a socket
416
- * will be destroyed. If the server receives new data before the keep-alive
417
- * timeout has fired, it will reset the regular inactivity timeout, i.e., `server.timeout`.
422
+ * will be destroyed.
423
+ *
424
+ * This timeout value is combined with the
425
+ * `server.keepAliveTimeoutBuffer` option to determine the actual socket
426
+ * timeout, calculated as:
427
+ * socketTimeout = keepAliveTimeout + keepAliveTimeoutBuffer
428
+ * If the server receives new data before the keep-alive timeout has fired, it
429
+ * will reset the regular inactivity timeout, i.e., `server.timeout`.
418
430
  *
419
431
  * A value of `0` will disable the keep-alive timeout behavior on incoming
420
432
  * connections.
421
- * A value of `0` makes the http server behave similarly to Node.js versions prior
433
+ * A value of `0` makes the HTTP server behave similarly to Node.js versions prior
422
434
  * to 8.0.0, which did not have a keep-alive timeout.
423
435
  *
424
436
  * The socket timeout logic is set up on connection, so changing this value only
@@ -426,6 +438,18 @@ declare module "http" {
426
438
  * @since v8.0.0
427
439
  */
428
440
  keepAliveTimeout: number;
441
+ /**
442
+ * An additional buffer time added to the
443
+ * `server.keepAliveTimeout` to extend the internal socket timeout.
444
+ *
445
+ * This buffer helps reduce connection reset (`ECONNRESET`) errors by increasing
446
+ * the socket timeout slightly beyond the advertised keep-alive timeout.
447
+ *
448
+ * This option applies only to new incoming connections.
449
+ * @since v24.6.0
450
+ * @default 1000
451
+ */
452
+ keepAliveTimeoutBuffer: number;
429
453
  /**
430
454
  * Sets the timeout value in milliseconds for receiving the entire request from
431
455
  * the client.
@@ -1419,7 +1443,15 @@ declare module "http" {
1419
1443
  */
1420
1444
  destroy(error?: Error): this;
1421
1445
  }
1422
- interface AgentOptions extends Partial<TcpSocketConnectOpts> {
1446
+ interface ProxyEnv extends NodeJS.ProcessEnv {
1447
+ HTTP_PROXY?: string | undefined;
1448
+ HTTPS_PROXY?: string | undefined;
1449
+ NO_PROXY?: string | undefined;
1450
+ http_proxy?: string | undefined;
1451
+ https_proxy?: string | undefined;
1452
+ no_proxy?: string | undefined;
1453
+ }
1454
+ interface AgentOptions extends NodeJS.PartialOptions<TcpSocketConnectOpts> {
1423
1455
  /**
1424
1456
  * Keep sockets around in a pool to be used by other requests in the future. Default = false
1425
1457
  */
@@ -1429,6 +1461,16 @@ declare module "http" {
1429
1461
  * Only relevant if keepAlive is set to true.
1430
1462
  */
1431
1463
  keepAliveMsecs?: number | undefined;
1464
+ /**
1465
+ * Milliseconds to subtract from
1466
+ * the server-provided `keep-alive: timeout=...` hint when determining socket
1467
+ * expiration time. This buffer helps ensure the agent closes the socket
1468
+ * slightly before the server does, reducing the chance of sending a request
1469
+ * on a socket that’s about to be closed by the server.
1470
+ * @since v24.7.0
1471
+ * @default 1000
1472
+ */
1473
+ agentKeepAliveTimeoutBuffer?: number | undefined;
1432
1474
  /**
1433
1475
  * Maximum number of sockets to allow per host. Default for Node 0.10 is 5, default for Node 0.12 is Infinity
1434
1476
  */
@@ -1450,6 +1492,22 @@ declare module "http" {
1450
1492
  * @default `lifo`
1451
1493
  */
1452
1494
  scheduling?: "fifo" | "lifo" | undefined;
1495
+ /**
1496
+ * Environment variables for proxy configuration. See
1497
+ * [Built-in Proxy Support](https://nodejs.org/docs/latest-v24.x/api/http.html#built-in-proxy-support) for details.
1498
+ * @since v24.5.0
1499
+ */
1500
+ proxyEnv?: ProxyEnv | undefined;
1501
+ /**
1502
+ * Default port to use when the port is not specified in requests.
1503
+ * @since v24.5.0
1504
+ */
1505
+ defaultPort?: number | undefined;
1506
+ /**
1507
+ * The protocol to use for the agent.
1508
+ * @since v24.5.0
1509
+ */
1510
+ protocol?: string | undefined;
1453
1511
  }
1454
1512
  /**
1455
1513
  * An `Agent` is responsible for managing connection persistence
@@ -1591,7 +1649,7 @@ declare module "http" {
1591
1649
  createConnection(
1592
1650
  options: ClientRequestArgs,
1593
1651
  callback?: (err: Error | null, stream: stream.Duplex) => void,
1594
- ): stream.Duplex;
1652
+ ): stream.Duplex | null | undefined;
1595
1653
  /**
1596
1654
  * Called when `socket` is detached from a request and could be persisted by the`Agent`. Default behavior is to:
1597
1655
  *
@@ -2028,18 +2086,18 @@ declare module "http" {
2028
2086
  */
2029
2087
  const maxHeaderSize: number;
2030
2088
  /**
2031
- * A browser-compatible implementation of [WebSocket](https://nodejs.org/docs/latest/api/http.html#websocket).
2089
+ * A browser-compatible implementation of `WebSocket`.
2032
2090
  * @since v22.5.0
2033
2091
  */
2034
- const WebSocket: import("undici-types").WebSocket;
2092
+ const WebSocket: typeof import("undici-types").WebSocket;
2035
2093
  /**
2036
2094
  * @since v22.5.0
2037
2095
  */
2038
- const CloseEvent: import("undici-types").CloseEvent;
2096
+ const CloseEvent: typeof import("undici-types").CloseEvent;
2039
2097
  /**
2040
2098
  * @since v22.5.0
2041
2099
  */
2042
- const MessageEvent: import("undici-types").MessageEvent;
2100
+ const MessageEvent: typeof import("undici-types").MessageEvent;
2043
2101
  }
2044
2102
  declare module "node:http" {
2045
2103
  export * from "http";
node/http2.d.ts CHANGED
@@ -51,14 +51,15 @@ declare module "http2" {
51
51
  length: number;
52
52
  }
53
53
  export interface ServerStreamFileResponseOptions {
54
- // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
55
- statCheck?(stats: fs.Stats, headers: OutgoingHttpHeaders, statOptions: StatOptions): void | boolean;
54
+ statCheck?:
55
+ | ((stats: fs.Stats, headers: OutgoingHttpHeaders, statOptions: StatOptions) => void)
56
+ | undefined;
56
57
  waitForTrailers?: boolean | undefined;
57
58
  offset?: number | undefined;
58
59
  length?: number | undefined;
59
60
  }
60
61
  export interface ServerStreamFileResponseOptionsWithError extends ServerStreamFileResponseOptions {
61
- onError?(err: NodeJS.ErrnoException): void;
62
+ onError?: ((err: NodeJS.ErrnoException) => void) | undefined;
62
63
  }
63
64
  export interface Http2Stream extends stream.Duplex {
64
65
  /**
@@ -423,7 +424,7 @@ declare module "http2" {
423
424
  * ```
424
425
  * @since v8.4.0
425
426
  */
426
- respond(headers?: OutgoingHttpHeaders, options?: ServerStreamResponseOptions): void;
427
+ respond(headers?: OutgoingHttpHeaders | readonly string[], options?: ServerStreamResponseOptions): void;
427
428
  /**
428
429
  * Initiates a response whose data is read from the given file descriptor. No
429
430
  * validation is performed on the given file descriptor. If an error occurs while
node/https.d.ts CHANGED
@@ -8,20 +8,17 @@ declare module "https" {
8
8
  import * as tls from "node:tls";
9
9
  import * as http from "node:http";
10
10
  import { URL } from "node:url";
11
- type ServerOptions<
11
+ interface ServerOptions<
12
12
  Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
13
13
  Response extends typeof http.ServerResponse<InstanceType<Request>> = typeof http.ServerResponse,
14
- > = tls.SecureContextOptions & tls.TlsOptions & http.ServerOptions<Request, Response>;
15
- type RequestOptions =
16
- & http.RequestOptions
17
- & tls.SecureContextOptions
18
- & {
19
- checkServerIdentity?:
20
- | ((hostname: string, cert: tls.DetailedPeerCertificate) => Error | undefined)
21
- | undefined;
22
- rejectUnauthorized?: boolean | undefined; // Defaults to true
23
- servername?: string | undefined; // SNI TLS Extension
24
- };
14
+ > extends http.ServerOptions<Request, Response>, tls.TlsOptions {}
15
+ interface RequestOptions extends http.RequestOptions, tls.SecureContextOptions {
16
+ checkServerIdentity?:
17
+ | ((hostname: string, cert: tls.DetailedPeerCertificate) => Error | undefined)
18
+ | undefined;
19
+ rejectUnauthorized?: boolean | undefined; // Defaults to true
20
+ servername?: string | undefined; // SNI TLS Extension
21
+ }
25
22
  interface AgentOptions extends http.AgentOptions, tls.ConnectionOptions {
26
23
  maxCachedSessions?: number | undefined;
27
24
  }
@@ -32,6 +29,11 @@ declare module "https" {
32
29
  class Agent extends http.Agent {
33
30
  constructor(options?: AgentOptions);
34
31
  options: AgentOptions;
32
+ createConnection(
33
+ options: RequestOptions,
34
+ callback?: (err: Error | null, stream: Duplex) => void,
35
+ ): Duplex | null | undefined;
36
+ getName(options?: RequestOptions): string;
35
37
  }
36
38
  interface Server<
37
39
  Request extends typeof http.IncomingMessage = typeof http.IncomingMessage,
node/index.d.ts CHANGED
@@ -38,6 +38,14 @@
38
38
 
39
39
  // Definitions for Node.js modules that are not specific to any version of TypeScript:
40
40
  /// <reference path="globals.d.ts" />
41
+ /// <reference path="web-globals/abortcontroller.d.ts" />
42
+ /// <reference path="web-globals/crypto.d.ts" />
43
+ /// <reference path="web-globals/domexception.d.ts" />
44
+ /// <reference path="web-globals/events.d.ts" />
45
+ /// <reference path="web-globals/fetch.d.ts" />
46
+ /// <reference path="web-globals/navigator.d.ts" />
47
+ /// <reference path="web-globals/storage.d.ts" />
48
+ /// <reference path="web-globals/streams.d.ts" />
41
49
  /// <reference path="assert.d.ts" />
42
50
  /// <reference path="assert/strict.d.ts" />
43
51
  /// <reference path="async_hooks.d.ts" />
@@ -51,9 +59,7 @@
51
59
  /// <reference path="diagnostics_channel.d.ts" />
52
60
  /// <reference path="dns.d.ts" />
53
61
  /// <reference path="dns/promises.d.ts" />
54
- /// <reference path="dns/promises.d.ts" />
55
62
  /// <reference path="domain.d.ts" />
56
- /// <reference path="dom-events.d.ts" />
57
63
  /// <reference path="events.d.ts" />
58
64
  /// <reference path="fs.d.ts" />
59
65
  /// <reference path="fs/promises.d.ts" />
@@ -61,6 +67,7 @@
61
67
  /// <reference path="http2.d.ts" />
62
68
  /// <reference path="https.d.ts" />
63
69
  /// <reference path="inspector.d.ts" />
70
+ /// <reference path="inspector.generated.d.ts" />
64
71
  /// <reference path="module.d.ts" />
65
72
  /// <reference path="net.d.ts" />
66
73
  /// <reference path="os.d.ts" />