@trpc/server 11.0.0-rc.666 → 11.0.0-rc.678

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.
@@ -1 +1 @@
1
- {"version":3,"file":"fastifyRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/fastify/fastifyRequestHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAEL,KAAK,sBAAsB,EAE5B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAGL,KAAK,2BAA2B,EACjC,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,qBAAqB,CAC/B,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,cAAc,EAC/B,SAAS,SAAS,YAAY,IAC5B,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,GAC3C,2BAA2B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAE5D,KAAK,4BAA4B,CAC/B,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,cAAc,EAC/B,SAAS,SAAS,YAAY,IAC5B,qBAAqB,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,GAAG;IACxD,GAAG,EAAE,QAAQ,CAAC;IACd,GAAG,EAAE,SAAS,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAsB,qBAAqB,CACzC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,cAAc,EAC/B,SAAS,SAAS,YAAY,EAC9B,IAAI,EAAE,4BAA4B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,iBAkCjE"}
1
+ {"version":3,"file":"fastifyRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/fastify/fastifyRequestHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAEL,KAAK,sBAAsB,EAE5B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAEL,KAAK,2BAA2B,EAEjC,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,qBAAqB,CAC/B,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,cAAc,EAC/B,SAAS,SAAS,YAAY,IAC5B,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,GAC3C,2BAA2B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAE5D,KAAK,4BAA4B,CAC/B,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,cAAc,EAC/B,SAAS,SAAS,YAAY,IAC5B,qBAAqB,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,GAAG;IACxD,GAAG,EAAE,QAAQ,CAAC;IACd,GAAG,EAAE,SAAS,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAsB,qBAAqB,CACzC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,cAAc,EAC/B,SAAS,SAAS,YAAY,EAC9B,IAAI,EAAE,4BAA4B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,iBAkCjE"}
@@ -1,15 +1,20 @@
1
1
  import type * as http from 'http';
2
- export interface IncomingMessageWithBody extends http.IncomingMessage {
2
+ export interface UniversalIncomingMessage extends Omit<http.IncomingMessage, 'socket'> {
3
3
  /**
4
4
  * Many adapters will add a `body` property to the incoming message and pre-parse the body
5
5
  */
6
6
  body?: unknown;
7
+ /**
8
+ * Socket is not always available in all deployments, so we need to make it optional
9
+ * @see https://github.com/trpc/trpc/issues/6341
10
+ */
11
+ socket?: http.IncomingMessage['socket'];
7
12
  }
8
- export declare function createURL(req: http.IncomingMessage): URL;
13
+ export declare function createURL(req: UniversalIncomingMessage): URL;
9
14
  /**
10
15
  * Convert an [`IncomingMessage`](https://nodejs.org/api/http.html#class-httpincomingmessage) to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
11
16
  */
12
- export declare function incomingMessageToRequest(req: http.IncomingMessage, res: http.ServerResponse, opts: {
17
+ export declare function incomingMessageToRequest(req: UniversalIncomingMessage, res: http.ServerResponse, opts: {
13
18
  /**
14
19
  * Max body size in bytes. If the body is larger than this, the request will be aborted
15
20
  */
@@ -1 +1 @@
1
- {"version":3,"file":"incomingMessageToRequest.d.ts","sourceRoot":"","sources":["../../../src/adapters/node-http/incomingMessageToRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,MAAM,CAAC;AAGlC,MAAM,WAAW,uBAAwB,SAAQ,IAAI,CAAC,eAAe;IACnE;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAiED,wBAAgB,SAAS,CAAC,GAAG,EAAE,IAAI,CAAC,eAAe,GAAG,GAAG,CAkBxD;AAwBD;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,IAAI,CAAC,eAAe,EACzB,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,IAAI,EAAE;IACJ;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,GACA,OAAO,CAqCT"}
1
+ {"version":3,"file":"incomingMessageToRequest.d.ts","sourceRoot":"","sources":["../../../src/adapters/node-http/incomingMessageToRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,IAAI,MAAM,MAAM,CAAC;AAGlC,MAAM,WAAW,wBACf,SAAQ,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE,QAAQ,CAAC;IAC5C;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;CACzC;AAiED,wBAAgB,SAAS,CAAC,GAAG,EAAE,wBAAwB,GAAG,GAAG,CAkB5D;AAwBD;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,GAAG,EAAE,wBAAwB,EAC7B,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,IAAI,EAAE;IACJ;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,GACA,OAAO,CAqCT"}
@@ -8,14 +8,16 @@ require('../../unstable-core-do-not-import/rootConfig.js');
8
8
  function createBody(req, opts) {
9
9
  // Some adapters will pre-parse the body and add it to the request object
10
10
  if ('body' in req) {
11
+ if (req.body === undefined) {
12
+ // If body property exists but is undefined, return undefined
13
+ return undefined;
14
+ }
11
15
  // If the body is already a string, return it directly
12
16
  if (typeof req.body === 'string') {
13
17
  return req.body;
14
- } else if (req.body !== undefined) {
15
- return JSON.stringify(req.body);
16
18
  }
17
- // If body property exists but is undefined, return undefined
18
- return undefined;
19
+ // If body exists but isn't a string, stringify it as JSON
20
+ return JSON.stringify(req.body);
19
21
  }
20
22
  let size = 0;
21
23
  let hasClosed = false;
@@ -88,12 +90,12 @@ function createHeaders(incoming) {
88
90
  const ac = new AbortController();
89
91
  const onAbort = ()=>{
90
92
  res.off('close', onAbort);
91
- req.socket.off('end', onAbort);
93
+ req.socket?.off('end', onAbort);
92
94
  // abort the request
93
95
  ac.abort();
94
96
  };
95
97
  res.once('close', onAbort);
96
- req.socket.once('end', onAbort);
98
+ req.socket?.once('end', onAbort);
97
99
  // Get host from either regular header or HTTP/2 pseudo-header
98
100
  const url = createURL(req);
99
101
  const init = {
@@ -6,14 +6,16 @@ import '../../unstable-core-do-not-import/rootConfig.mjs';
6
6
  function createBody(req, opts) {
7
7
  // Some adapters will pre-parse the body and add it to the request object
8
8
  if ('body' in req) {
9
+ if (req.body === undefined) {
10
+ // If body property exists but is undefined, return undefined
11
+ return undefined;
12
+ }
9
13
  // If the body is already a string, return it directly
10
14
  if (typeof req.body === 'string') {
11
15
  return req.body;
12
- } else if (req.body !== undefined) {
13
- return JSON.stringify(req.body);
14
16
  }
15
- // If body property exists but is undefined, return undefined
16
- return undefined;
17
+ // If body exists but isn't a string, stringify it as JSON
18
+ return JSON.stringify(req.body);
17
19
  }
18
20
  let size = 0;
19
21
  let hasClosed = false;
@@ -86,12 +88,12 @@ function createHeaders(incoming) {
86
88
  const ac = new AbortController();
87
89
  const onAbort = ()=>{
88
90
  res.off('close', onAbort);
89
- req.socket.off('end', onAbort);
91
+ req.socket?.off('end', onAbort);
90
92
  // abort the request
91
93
  ac.abort();
92
94
  };
93
95
  res.once('close', onAbort);
94
- req.socket.once('end', onAbort);
96
+ req.socket?.once('end', onAbort);
95
97
  // Get host from either regular header or HTTP/2 pseudo-header
96
98
  const url = createURL(req);
97
99
  const init = {
@@ -1,7 +1,7 @@
1
1
  {
2
- "bundleSize": 186969,
3
- "bundleOrigSize": 219149,
4
- "bundleReduction": 14.68,
2
+ "bundleSize": 187045,
3
+ "bundleOrigSize": 219372,
4
+ "bundleReduction": 14.74,
5
5
  "modules": [
6
6
  {
7
7
  "id": "/src/unstable-core-do-not-import/stream/jsonl.ts",
@@ -47,7 +47,7 @@
47
47
  "dependents": [
48
48
  "/src/adapters/fastify/fastifyTRPCPlugin.ts"
49
49
  ],
50
- "percent": 10.77,
50
+ "percent": 10.76,
51
51
  "reduction": 0
52
52
  },
53
53
  {
@@ -64,7 +64,7 @@
64
64
  "/src/unstable-core-do-not-import.ts",
65
65
  "/src/unstable-core-do-not-import/http/resolveResponse.ts"
66
66
  ],
67
- "percent": 6.65,
67
+ "percent": 6.64,
68
68
  "reduction": 0
69
69
  },
70
70
  {
@@ -158,7 +158,7 @@
158
158
  "dependents": [
159
159
  "/src/adapters/aws-lambda/index.ts"
160
160
  ],
161
- "percent": 2.9,
161
+ "percent": 2.89,
162
162
  "reduction": 11.51
163
163
  },
164
164
  {
@@ -193,9 +193,25 @@
193
193
  "dependents": [
194
194
  "/src/unstable-core-do-not-import/stream/sse.ts"
195
195
  ],
196
- "percent": 2.38,
196
+ "percent": 2.37,
197
197
  "reduction": 0
198
198
  },
199
+ {
200
+ "id": "/src/adapters/node-http/incomingMessageToRequest.ts",
201
+ "size": 3914,
202
+ "origSize": 4578,
203
+ "renderedExports": [
204
+ "createURL",
205
+ "incomingMessageToRequest"
206
+ ],
207
+ "removedExports": [],
208
+ "dependents": [
209
+ "/src/adapters/node-http/index.ts",
210
+ "/src/adapters/node-http/nodeHTTPRequestHandler.ts"
211
+ ],
212
+ "percent": 2.09,
213
+ "reduction": 14.5
214
+ },
199
215
  {
200
216
  "id": "/src/observable/operators.ts",
201
217
  "size": 3910,
@@ -214,22 +230,6 @@
214
230
  "percent": 2.09,
215
231
  "reduction": 1.66
216
232
  },
217
- {
218
- "id": "/src/adapters/node-http/incomingMessageToRequest.ts",
219
- "size": 3838,
220
- "origSize": 4355,
221
- "renderedExports": [
222
- "createURL",
223
- "incomingMessageToRequest"
224
- ],
225
- "removedExports": [],
226
- "dependents": [
227
- "/src/adapters/node-http/index.ts",
228
- "/src/adapters/node-http/nodeHTTPRequestHandler.ts"
229
- ],
230
- "percent": 2.05,
231
- "reduction": 11.87
232
- },
233
233
  {
234
234
  "id": "/src/adapters/next-app-dir/nextAppDirCaller.ts",
235
235
  "size": 3244,
@@ -241,7 +241,7 @@
241
241
  "dependents": [
242
242
  "/src/adapters/next-app-dir.ts"
243
243
  ],
244
- "percent": 1.74,
244
+ "percent": 1.73,
245
245
  "reduction": 22.52
246
246
  },
247
247
  {
@@ -272,9 +272,9 @@
272
272
  "removedExports": [],
273
273
  "dependents": [
274
274
  "/src/unstable-core-do-not-import.ts",
275
+ "/src/unstable-core-do-not-import/http/resolveResponse.ts",
275
276
  "/src/unstable-core-do-not-import/initTRPC.ts",
276
- "/src/unstable-core-do-not-import/router.ts",
277
- "/src/unstable-core-do-not-import/http/resolveResponse.ts"
277
+ "/src/unstable-core-do-not-import/router.ts"
278
278
  ],
279
279
  "percent": 1.46,
280
280
  "reduction": 45.98
@@ -334,13 +334,13 @@
334
334
  "removedExports": [],
335
335
  "dependents": [
336
336
  "/src/unstable-core-do-not-import.ts",
337
+ "/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
338
+ "/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
339
+ "/src/unstable-core-do-not-import/http/resolveResponse.ts",
337
340
  "/src/unstable-core-do-not-import/error/TRPCError.ts",
338
341
  "/src/unstable-core-do-not-import/transformer.ts",
339
342
  "/src/unstable-core-do-not-import/middleware.ts",
340
343
  "/src/unstable-core-do-not-import/router.ts",
341
- "/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
342
- "/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
343
- "/src/unstable-core-do-not-import/http/resolveResponse.ts",
344
344
  "/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
345
345
  "/src/unstable-core-do-not-import/http/contentType.ts",
346
346
  "/src/unstable-core-do-not-import/http/isAbortError.ts",
@@ -363,10 +363,10 @@
363
363
  "removedExports": [],
364
364
  "dependents": [
365
365
  "/src/unstable-core-do-not-import.ts",
366
- "/src/unstable-core-do-not-import/middleware.ts",
367
- "/src/unstable-core-do-not-import/router.ts",
368
366
  "/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
369
367
  "/src/unstable-core-do-not-import/http/resolveResponse.ts",
368
+ "/src/unstable-core-do-not-import/middleware.ts",
369
+ "/src/unstable-core-do-not-import/router.ts",
370
370
  "/src/unstable-core-do-not-import/http/contentType.ts",
371
371
  "/src/unstable-core-do-not-import/procedureBuilder.ts",
372
372
  "/src/unstable-core-do-not-import/stream/sse.ts"
@@ -433,8 +433,8 @@
433
433
  "removedExports": [],
434
434
  "dependents": [
435
435
  "/src/unstable-core-do-not-import.ts",
436
- "/src/unstable-core-do-not-import/error/getErrorShape.ts",
437
- "/src/unstable-core-do-not-import/http/resolveResponse.ts"
436
+ "/src/unstable-core-do-not-import/http/resolveResponse.ts",
437
+ "/src/unstable-core-do-not-import/error/getErrorShape.ts"
438
438
  ],
439
439
  "percent": 1.12,
440
440
  "reduction": 18.54
@@ -821,24 +821,24 @@
821
821
  "reduction": 93.9
822
822
  },
823
823
  {
824
- "id": "/src/index.ts",
824
+ "id": "/src/http.ts",
825
825
  "size": 0,
826
- "origSize": 32,
826
+ "origSize": 37,
827
827
  "renderedExports": [],
828
828
  "removedExports": [],
829
- "dependents": [],
829
+ "dependents": [
830
+ "/src/adapters/ws.ts"
831
+ ],
830
832
  "percent": 0,
831
833
  "reduction": 100
832
834
  },
833
835
  {
834
- "id": "/src/http.ts",
836
+ "id": "/src/index.ts",
835
837
  "size": 0,
836
- "origSize": 37,
838
+ "origSize": 32,
837
839
  "renderedExports": [],
838
840
  "removedExports": [],
839
- "dependents": [
840
- "/src/adapters/ws.ts"
841
- ],
841
+ "dependents": [],
842
842
  "percent": 0,
843
843
  "reduction": 100
844
844
  },
@@ -870,8 +870,8 @@
870
870
  "removedExports": [],
871
871
  "dependents": [
872
872
  "/src/adapters/express.ts",
873
- "/src/adapters/standalone.ts",
874
873
  "/src/adapters/next.ts",
874
+ "/src/adapters/standalone.ts",
875
875
  "/src/adapters/ws.ts",
876
876
  "/src/adapters/node-http/nodeHTTPRequestHandler.ts",
877
877
  "/src/adapters/next-app-dir/nextAppDirCaller.ts",
@@ -903,9 +903,9 @@
903
903
  "reduction": 100
904
904
  },
905
905
  {
906
- "id": "/src/adapters/fastify/index.ts",
906
+ "id": "/src/adapters/fetch/index.ts",
907
907
  "size": 0,
908
- "origSize": 78,
908
+ "origSize": 64,
909
909
  "renderedExports": [],
910
910
  "removedExports": [],
911
911
  "dependents": [],
@@ -913,9 +913,9 @@
913
913
  "reduction": 100
914
914
  },
915
915
  {
916
- "id": "/src/adapters/fetch/index.ts",
916
+ "id": "/src/adapters/fastify/index.ts",
917
917
  "size": 0,
918
- "origSize": 64,
918
+ "origSize": 78,
919
919
  "renderedExports": [],
920
920
  "removedExports": [],
921
921
  "dependents": [],
@@ -930,8 +930,8 @@
930
930
  "removedExports": [],
931
931
  "dependents": [
932
932
  "/src/adapters/express.ts",
933
- "/src/adapters/standalone.ts",
934
933
  "/src/adapters/next.ts",
934
+ "/src/adapters/standalone.ts",
935
935
  "/src/adapters/ws.ts",
936
936
  "/src/adapters/fastify/fastifyRequestHandler.ts"
937
937
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/server",
3
- "version": "11.0.0-rc.666+99556c074",
3
+ "version": "11.0.0-rc.678+29a2f0d18",
4
4
  "description": "The tRPC server library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -133,14 +133,14 @@
133
133
  "fastify-plugin": "^5.0.0",
134
134
  "hash-sum": "^2.0.0",
135
135
  "myzod": "^1.3.1",
136
- "next": "^15.0.4",
136
+ "next": "^15.1.3",
137
137
  "react": "^19.0.0",
138
138
  "react-dom": "^19.0.0",
139
139
  "rollup": "^4.24.4",
140
140
  "superjson": "^1.12.4",
141
141
  "superstruct": "^2.0.0",
142
142
  "tsx": "^4.0.0",
143
- "typescript": "^5.7.0",
143
+ "typescript": "^5.7.2",
144
144
  "valibot": "^0.42.0",
145
145
  "ws": "^8.0.0",
146
146
  "yup": "^1.0.0",
@@ -150,7 +150,7 @@
150
150
  "https://trpc.io/sponsor"
151
151
  ],
152
152
  "peerDependencies": {
153
- "typescript": ">=5.6.2"
153
+ "typescript": ">=5.7.2"
154
154
  },
155
- "gitHead": "99556c0744cf8da7784c03d577f65cf5cd4dd624"
155
+ "gitHead": "29a2f0d1802a4fe286ae56715ac1a06315f8f858"
156
156
  }
@@ -19,8 +19,8 @@ import {
19
19
  // @trpc/server/node-http
20
20
  import {
21
21
  incomingMessageToRequest,
22
- type IncomingMessageWithBody,
23
22
  type NodeHTTPCreateContextOption,
23
+ type UniversalIncomingMessage,
24
24
  } from '../node-http';
25
25
 
26
26
  export type FastifyHandlerOptions<
@@ -54,7 +54,7 @@ export async function fastifyRequestHandler<
54
54
  });
55
55
  };
56
56
 
57
- const incomingMessage = opts.req.raw as IncomingMessageWithBody;
57
+ const incomingMessage: UniversalIncomingMessage = opts.req.raw;
58
58
 
59
59
  // monkey-path body to the IncomingMessage
60
60
  if ('body' in opts.req) {
@@ -1,15 +1,21 @@
1
1
  import type * as http from 'http';
2
2
  import { TRPCError } from '../../@trpc/server';
3
3
 
4
- export interface IncomingMessageWithBody extends http.IncomingMessage {
4
+ export interface UniversalIncomingMessage
5
+ extends Omit<http.IncomingMessage, 'socket'> {
5
6
  /**
6
7
  * Many adapters will add a `body` property to the incoming message and pre-parse the body
7
8
  */
8
9
  body?: unknown;
10
+ /**
11
+ * Socket is not always available in all deployments, so we need to make it optional
12
+ * @see https://github.com/trpc/trpc/issues/6341
13
+ */
14
+ socket?: http.IncomingMessage['socket'];
9
15
  }
10
16
 
11
17
  function createBody(
12
- req: http.IncomingMessage,
18
+ req: UniversalIncomingMessage,
13
19
  opts: {
14
20
  /**
15
21
  * Max body size in bytes. If the body is larger than this, the request will be aborted
@@ -19,16 +25,16 @@ function createBody(
19
25
  ): RequestInit['body'] {
20
26
  // Some adapters will pre-parse the body and add it to the request object
21
27
  if ('body' in req) {
28
+ if (req.body === undefined) {
29
+ // If body property exists but is undefined, return undefined
30
+ return undefined;
31
+ }
22
32
  // If the body is already a string, return it directly
23
33
  if (typeof req.body === 'string') {
24
34
  return req.body;
25
35
  }
26
36
  // If body exists but isn't a string, stringify it as JSON
27
- else if (req.body !== undefined) {
28
- return JSON.stringify(req.body);
29
- }
30
- // If body property exists but is undefined, return undefined
31
- return undefined;
37
+ return JSON.stringify(req.body);
32
38
  }
33
39
  let size = 0;
34
40
  let hasClosed = false;
@@ -71,7 +77,7 @@ function createBody(
71
77
  },
72
78
  });
73
79
  }
74
- export function createURL(req: http.IncomingMessage): URL {
80
+ export function createURL(req: UniversalIncomingMessage): URL {
75
81
  try {
76
82
  const protocol =
77
83
  req.socket && 'encrypted' in req.socket && req.socket.encrypted
@@ -117,7 +123,7 @@ function createHeaders(incoming: http.IncomingHttpHeaders): Headers {
117
123
  * Convert an [`IncomingMessage`](https://nodejs.org/api/http.html#class-httpincomingmessage) to a [`Request`](https://developer.mozilla.org/en-US/docs/Web/API/Request)
118
124
  */
119
125
  export function incomingMessageToRequest(
120
- req: http.IncomingMessage,
126
+ req: UniversalIncomingMessage,
121
127
  res: http.ServerResponse,
122
128
  opts: {
123
129
  /**
@@ -130,14 +136,14 @@ export function incomingMessageToRequest(
130
136
 
131
137
  const onAbort = () => {
132
138
  res.off('close', onAbort);
133
- req.socket.off('end', onAbort);
139
+ req.socket?.off('end', onAbort);
134
140
 
135
141
  // abort the request
136
142
  ac.abort();
137
143
  };
138
144
 
139
145
  res.once('close', onAbort);
140
- req.socket.once('end', onAbort);
146
+ req.socket?.once('end', onAbort);
141
147
 
142
148
  // Get host from either regular header or HTTP/2 pseudo-header
143
149
  const url = createURL(req);