@trpc/server 11.0.0-alpha-tmp-12-06-react.667 → 11.0.0-alpha-tmp-issues-6374.694
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/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -1
- package/dist/adapters/node-http/incomingMessageToRequest.d.ts +10 -3
- package/dist/adapters/node-http/incomingMessageToRequest.d.ts.map +1 -1
- package/dist/adapters/node-http/incomingMessageToRequest.js +8 -6
- package/dist/adapters/node-http/incomingMessageToRequest.mjs +8 -6
- package/dist/bundle-analysis.json +60 -60
- package/dist/unstable-core-do-not-import/createProxy.d.ts +1 -1
- package/dist/unstable-core-do-not-import/createProxy.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/createProxy.js +2 -1
- package/dist/unstable-core-do-not-import/createProxy.mjs +2 -1
- package/dist/unstable-core-do-not-import/stream/sse.d.ts +1 -1
- package/dist/unstable-core-do-not-import/stream/sse.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/stream/sse.js +7 -3
- package/dist/unstable-core-do-not-import/stream/sse.mjs +7 -3
- package/package.json +7 -7
- package/src/adapters/fastify/fastifyRequestHandler.ts +2 -2
- package/src/adapters/node-http/incomingMessageToRequest.ts +19 -11
- package/src/unstable-core-do-not-import/createProxy.ts +3 -2
- package/src/unstable-core-do-not-import/stream/sse.ts +28 -21
|
@@ -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,
|
|
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,22 @@
|
|
|
1
1
|
import type * as http from 'http';
|
|
2
|
-
export interface
|
|
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
|
+
* The socket object provided in the request does not fully implement the expected Node.js Socket interface.
|
|
11
|
+
* @see https://github.com/trpc/trpc/pull/6358
|
|
12
|
+
*/
|
|
13
|
+
socket?: Partial<http.IncomingMessage['socket']>;
|
|
7
14
|
}
|
|
8
|
-
export declare function createURL(req:
|
|
15
|
+
export declare function createURL(req: UniversalIncomingMessage): URL;
|
|
9
16
|
/**
|
|
10
17
|
* 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
18
|
*/
|
|
12
|
-
export declare function incomingMessageToRequest(req:
|
|
19
|
+
export declare function incomingMessageToRequest(req: UniversalIncomingMessage, res: http.ServerResponse, opts: {
|
|
13
20
|
/**
|
|
14
21
|
* Max body size in bytes. If the body is larger than this, the request will be aborted
|
|
15
22
|
*/
|
|
@@ -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,
|
|
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;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC;CAClD;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
|
|
18
|
-
return
|
|
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
|
|
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
|
|
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
|
|
16
|
-
return
|
|
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
|
|
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
|
|
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":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction": 14.
|
|
2
|
+
"bundleSize": 187303,
|
|
3
|
+
"bundleOrigSize": 219810,
|
|
4
|
+
"bundleReduction": 14.79,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/unstable-core-do-not-import/stream/jsonl.ts",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"/src/unstable-core-do-not-import.ts",
|
|
18
18
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
19
19
|
],
|
|
20
|
-
"percent": 11.
|
|
20
|
+
"percent": 11.7,
|
|
21
21
|
"reduction": 0
|
|
22
22
|
},
|
|
23
23
|
{
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dependents": [
|
|
32
32
|
"/src/unstable-core-do-not-import.ts"
|
|
33
33
|
],
|
|
34
|
-
"percent": 11.
|
|
34
|
+
"percent": 11.28,
|
|
35
35
|
"reduction": 0
|
|
36
36
|
},
|
|
37
37
|
{
|
|
@@ -47,13 +47,13 @@
|
|
|
47
47
|
"dependents": [
|
|
48
48
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
49
49
|
],
|
|
50
|
-
"percent": 10.
|
|
50
|
+
"percent": 10.75,
|
|
51
51
|
"reduction": 0
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
54
|
"id": "/src/unstable-core-do-not-import/stream/sse.ts",
|
|
55
|
-
"size":
|
|
56
|
-
"origSize":
|
|
55
|
+
"size": 12627,
|
|
56
|
+
"origSize": 12452,
|
|
57
57
|
"renderedExports": [
|
|
58
58
|
"sseStreamProducer",
|
|
59
59
|
"sseStreamConsumer",
|
|
@@ -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.
|
|
67
|
+
"percent": 6.74,
|
|
68
68
|
"reduction": 0
|
|
69
69
|
},
|
|
70
70
|
{
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
],
|
|
78
78
|
"removedExports": [],
|
|
79
79
|
"dependents": [],
|
|
80
|
-
"percent": 6.
|
|
80
|
+
"percent": 6.49,
|
|
81
81
|
"reduction": 11.62
|
|
82
82
|
},
|
|
83
83
|
{
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"/src/unstable-core-do-not-import.ts",
|
|
93
93
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
94
94
|
],
|
|
95
|
-
"percent": 4.
|
|
95
|
+
"percent": 4.1,
|
|
96
96
|
"reduction": 0
|
|
97
97
|
},
|
|
98
98
|
{
|
|
@@ -129,7 +129,7 @@
|
|
|
129
129
|
"/src/unstable-core-do-not-import/stream/sse.ts",
|
|
130
130
|
"/src/unstable-core-do-not-import/stream/utils/withPing.ts"
|
|
131
131
|
],
|
|
132
|
-
"percent": 3.
|
|
132
|
+
"percent": 3.11,
|
|
133
133
|
"reduction": 0
|
|
134
134
|
},
|
|
135
135
|
{
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
"/src/unstable-core-do-not-import.ts",
|
|
145
145
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
146
146
|
],
|
|
147
|
-
"percent": 3.
|
|
147
|
+
"percent": 3.09,
|
|
148
148
|
"reduction": 65.01
|
|
149
149
|
},
|
|
150
150
|
{
|
|
@@ -158,7 +158,7 @@
|
|
|
158
158
|
"dependents": [
|
|
159
159
|
"/src/adapters/aws-lambda/index.ts"
|
|
160
160
|
],
|
|
161
|
-
"percent": 2.
|
|
161
|
+
"percent": 2.89,
|
|
162
162
|
"reduction": 11.51
|
|
163
163
|
},
|
|
164
164
|
{
|
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
"/src/observable/operators.ts",
|
|
179
179
|
"/src/observable/behaviorSubject.ts"
|
|
180
180
|
],
|
|
181
|
-
"percent": 2.
|
|
181
|
+
"percent": 2.58,
|
|
182
182
|
"reduction": 0
|
|
183
183
|
},
|
|
184
184
|
{
|
|
@@ -193,9 +193,25 @@
|
|
|
193
193
|
"dependents": [
|
|
194
194
|
"/src/unstable-core-do-not-import/stream/sse.ts"
|
|
195
195
|
],
|
|
196
|
-
"percent": 2.
|
|
196
|
+
"percent": 2.37,
|
|
197
197
|
"reduction": 0
|
|
198
198
|
},
|
|
199
|
+
{
|
|
200
|
+
"id": "/src/adapters/node-http/incomingMessageToRequest.ts",
|
|
201
|
+
"size": 3918,
|
|
202
|
+
"origSize": 4751,
|
|
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": 17.53
|
|
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.
|
|
244
|
+
"percent": 1.73,
|
|
245
245
|
"reduction": 22.52
|
|
246
246
|
},
|
|
247
247
|
{
|
|
@@ -256,7 +256,7 @@
|
|
|
256
256
|
"dependents": [
|
|
257
257
|
"/src/adapters/node-http/index.ts"
|
|
258
258
|
],
|
|
259
|
-
"percent": 1.
|
|
259
|
+
"percent": 1.46,
|
|
260
260
|
"reduction": 16.3
|
|
261
261
|
},
|
|
262
262
|
{
|
|
@@ -348,9 +348,25 @@
|
|
|
348
348
|
"/src/unstable-core-do-not-import/stream/jsonl.ts",
|
|
349
349
|
"/src/unstable-core-do-not-import/stream/sse.ts"
|
|
350
350
|
],
|
|
351
|
-
"percent": 1.
|
|
351
|
+
"percent": 1.31,
|
|
352
352
|
"reduction": 17.51
|
|
353
353
|
},
|
|
354
|
+
{
|
|
355
|
+
"id": "/src/unstable-core-do-not-import/createProxy.ts",
|
|
356
|
+
"size": 2385,
|
|
357
|
+
"origSize": 2321,
|
|
358
|
+
"renderedExports": [
|
|
359
|
+
"createRecursiveProxy",
|
|
360
|
+
"createFlatProxy"
|
|
361
|
+
],
|
|
362
|
+
"removedExports": [],
|
|
363
|
+
"dependents": [
|
|
364
|
+
"/src/unstable-core-do-not-import.ts",
|
|
365
|
+
"/src/unstable-core-do-not-import/router.ts"
|
|
366
|
+
],
|
|
367
|
+
"percent": 1.27,
|
|
368
|
+
"reduction": 0
|
|
369
|
+
},
|
|
354
370
|
{
|
|
355
371
|
"id": "/src/unstable-core-do-not-import/error/TRPCError.ts",
|
|
356
372
|
"size": 2356,
|
|
@@ -374,22 +390,6 @@
|
|
|
374
390
|
"percent": 1.26,
|
|
375
391
|
"reduction": 0
|
|
376
392
|
},
|
|
377
|
-
{
|
|
378
|
-
"id": "/src/unstable-core-do-not-import/createProxy.ts",
|
|
379
|
-
"size": 2333,
|
|
380
|
-
"origSize": 2262,
|
|
381
|
-
"renderedExports": [
|
|
382
|
-
"createRecursiveProxy",
|
|
383
|
-
"createFlatProxy"
|
|
384
|
-
],
|
|
385
|
-
"removedExports": [],
|
|
386
|
-
"dependents": [
|
|
387
|
-
"/src/unstable-core-do-not-import.ts",
|
|
388
|
-
"/src/unstable-core-do-not-import/router.ts"
|
|
389
|
-
],
|
|
390
|
-
"percent": 1.25,
|
|
391
|
-
"reduction": 0
|
|
392
|
-
},
|
|
393
393
|
{
|
|
394
394
|
"id": "/src/adapters/fetch/fetchRequestHandler.ts",
|
|
395
395
|
"size": 2243,
|
|
@@ -436,7 +436,7 @@
|
|
|
436
436
|
"/src/unstable-core-do-not-import/error/getErrorShape.ts",
|
|
437
437
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
438
438
|
],
|
|
439
|
-
"percent": 1.
|
|
439
|
+
"percent": 1.11,
|
|
440
440
|
"reduction": 18.54
|
|
441
441
|
},
|
|
442
442
|
{
|
|
@@ -743,7 +743,7 @@
|
|
|
743
743
|
"/src/unstable-core-do-not-import.ts",
|
|
744
744
|
"/src/unstable-core-do-not-import/stream/jsonl.ts"
|
|
745
745
|
],
|
|
746
|
-
"percent": 0.
|
|
746
|
+
"percent": 0.16,
|
|
747
747
|
"reduction": 25.9
|
|
748
748
|
},
|
|
749
749
|
{
|
|
@@ -843,9 +843,9 @@
|
|
|
843
843
|
"reduction": 100
|
|
844
844
|
},
|
|
845
845
|
{
|
|
846
|
-
"id": "/src/
|
|
846
|
+
"id": "/src/shared.ts",
|
|
847
847
|
"size": 0,
|
|
848
|
-
"origSize":
|
|
848
|
+
"origSize": 653,
|
|
849
849
|
"renderedExports": [],
|
|
850
850
|
"removedExports": [],
|
|
851
851
|
"dependents": [],
|
|
@@ -853,9 +853,9 @@
|
|
|
853
853
|
"reduction": 100
|
|
854
854
|
},
|
|
855
855
|
{
|
|
856
|
-
"id": "/src/
|
|
856
|
+
"id": "/src/rpc.ts",
|
|
857
857
|
"size": 0,
|
|
858
|
-
"origSize":
|
|
858
|
+
"origSize": 36,
|
|
859
859
|
"renderedExports": [],
|
|
860
860
|
"removedExports": [],
|
|
861
861
|
"dependents": [],
|
|
@@ -870,11 +870,11 @@
|
|
|
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
|
-
"/src/adapters/next-app-dir/nextAppDirCaller.ts",
|
|
877
876
|
"/src/adapters/node-http/nodeHTTPRequestHandler.ts",
|
|
877
|
+
"/src/adapters/next-app-dir/nextAppDirCaller.ts",
|
|
878
878
|
"/src/adapters/node-http/writeResponse.ts"
|
|
879
879
|
],
|
|
880
880
|
"percent": 0,
|
|
@@ -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
|
],
|
|
@@ -14,6 +14,6 @@ export declare const createRecursiveProxy: <TFaux = unknown>(callback: ProxyCall
|
|
|
14
14
|
*
|
|
15
15
|
* @internal
|
|
16
16
|
*/
|
|
17
|
-
export declare const createFlatProxy: <TFaux>(callback: (path: string & keyof TFaux) => any) => TFaux;
|
|
17
|
+
export declare const createFlatProxy: <TFaux>(callback: (path: (string & keyof TFaux) | symbol) => any) => TFaux;
|
|
18
18
|
export {};
|
|
19
19
|
//# sourceMappingURL=createProxy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createProxy.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/createProxy.ts"],"names":[],"mappings":"AAAA,UAAU,oBAAoB;IAC5B,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,IAAI,EAAE,SAAS,OAAO,EAAE,CAAC;CAC1B;AACD,KAAK,aAAa,GAAG,CAAC,IAAI,EAAE,oBAAoB,KAAK,OAAO,CAAC;AAqD7D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,KAAK,sBAC9B,aAAa,KACtB,KAAqE,CAAC;AAEzE;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,YACzB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,KAAK,KAAK,GAAG,
|
|
1
|
+
{"version":3,"file":"createProxy.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/createProxy.ts"],"names":[],"mappings":"AAAA,UAAU,oBAAoB;IAC5B,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,IAAI,EAAE,SAAS,OAAO,EAAE,CAAC;CAC1B;AACD,KAAK,aAAa,GAAG,CAAC,IAAI,EAAE,oBAAoB,KAAK,OAAO,CAAC;AAqD7D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,KAAK,sBAC9B,aAAa,KACtB,KAAqE,CAAC;AAEzE;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,YACzB,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,KAAK,CAAC,GAAG,MAAM,KAAK,GAAG,KACvD,KAYF,CAAC"}
|
|
@@ -62,7 +62,8 @@ function createInnerProxy(callback, path, memo) {
|
|
|
62
62
|
*/ const createFlatProxy = (callback)=>{
|
|
63
63
|
return new Proxy(noop, {
|
|
64
64
|
get (_obj, name) {
|
|
65
|
-
|
|
65
|
+
const type = typeof name;
|
|
66
|
+
if (type !== 'string' && type !== 'symbol' || name === 'then') {
|
|
66
67
|
// special case for if the proxy is accidentally treated
|
|
67
68
|
// like a PromiseLike (like in `Promise.resolve(proxy)`)
|
|
68
69
|
return undefined;
|
|
@@ -60,7 +60,8 @@ function createInnerProxy(callback, path, memo) {
|
|
|
60
60
|
*/ const createFlatProxy = (callback)=>{
|
|
61
61
|
return new Proxy(noop, {
|
|
62
62
|
get (_obj, name) {
|
|
63
|
-
|
|
63
|
+
const type = typeof name;
|
|
64
|
+
if (type !== 'string' && type !== 'symbol' || name === 'then') {
|
|
64
65
|
// special case for if the proxy is accidentally treated
|
|
65
66
|
// like a PromiseLike (like in `Promise.resolve(proxy)`)
|
|
66
67
|
return undefined;
|
|
@@ -54,7 +54,7 @@ export interface SSEStreamProducerOptions<TValue = unknown> {
|
|
|
54
54
|
*
|
|
55
55
|
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html
|
|
56
56
|
*/
|
|
57
|
-
export declare function sseStreamProducer<TValue = unknown>(opts: SSEStreamProducerOptions<TValue>): ReadableStream<
|
|
57
|
+
export declare function sseStreamProducer<TValue = unknown>(opts: SSEStreamProducerOptions<TValue>): ReadableStream<Uint8Array<ArrayBufferLike>>;
|
|
58
58
|
interface ConsumerStreamResultBase<TConfig extends ConsumerConfig> {
|
|
59
59
|
eventSource: InstanceType<TConfig['EventSource']> | null;
|
|
60
60
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/stream/sse.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAWpD,KAAK,SAAS,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;AACrC,KAAK,WAAW,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,0BAA0B,CAAC,EAAE,MAAM,CAAC;CACrC;AAED,MAAM,WAAW,wBAAwB,CAAC,MAAM,GAAG,OAAO;IACxD,SAAS,CAAC,E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AAO,MAAM,UAAU;;;;;CAKb,CAAC"}
|
|
@@ -174,7 +174,7 @@ const CONNECTED_EVENT = 'connected';
|
|
|
174
174
|
}
|
|
175
175
|
controller.enqueue('\n\n');
|
|
176
176
|
}
|
|
177
|
-
}));
|
|
177
|
+
})).pipeThrough(new TextEncoderStream());
|
|
178
178
|
}
|
|
179
179
|
async function withTimeout(opts) {
|
|
180
180
|
const env = {
|
|
@@ -270,8 +270,12 @@ async function withTimeout(opts) {
|
|
|
270
270
|
});
|
|
271
271
|
});
|
|
272
272
|
const onAbort = ()=>{
|
|
273
|
-
|
|
274
|
-
|
|
273
|
+
try {
|
|
274
|
+
eventSource.close();
|
|
275
|
+
controller.close();
|
|
276
|
+
} catch {
|
|
277
|
+
// ignore errors in case the controller is already closed
|
|
278
|
+
}
|
|
275
279
|
};
|
|
276
280
|
if (signal.aborted) {
|
|
277
281
|
onAbort();
|
|
@@ -172,7 +172,7 @@ const CONNECTED_EVENT = 'connected';
|
|
|
172
172
|
}
|
|
173
173
|
controller.enqueue('\n\n');
|
|
174
174
|
}
|
|
175
|
-
}));
|
|
175
|
+
})).pipeThrough(new TextEncoderStream());
|
|
176
176
|
}
|
|
177
177
|
async function withTimeout(opts) {
|
|
178
178
|
const env = {
|
|
@@ -268,8 +268,12 @@ async function withTimeout(opts) {
|
|
|
268
268
|
});
|
|
269
269
|
});
|
|
270
270
|
const onAbort = ()=>{
|
|
271
|
-
|
|
272
|
-
|
|
271
|
+
try {
|
|
272
|
+
eventSource.close();
|
|
273
|
+
controller.close();
|
|
274
|
+
} catch {
|
|
275
|
+
// ignore errors in case the controller is already closed
|
|
276
|
+
}
|
|
273
277
|
};
|
|
274
278
|
if (signal.aborted) {
|
|
275
279
|
onAbort();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/server",
|
|
3
|
-
"version": "11.0.0-alpha-tmp-
|
|
3
|
+
"version": "11.0.0-alpha-tmp-issues-6374.694+ce45f1c48",
|
|
4
4
|
"description": "The tRPC server library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
},
|
|
119
119
|
"devDependencies": {
|
|
120
120
|
"@fastify/websocket": "^10.0.1",
|
|
121
|
-
"@tanstack/react-query": "^5.
|
|
121
|
+
"@tanstack/react-query": "^5.62.8",
|
|
122
122
|
"@types/aws-lambda": "^8.10.137",
|
|
123
123
|
"@types/express": "^4.17.17",
|
|
124
124
|
"@types/hash-sum": "^1.0.0",
|
|
@@ -128,19 +128,19 @@
|
|
|
128
128
|
"@types/ws": "^8.2.0",
|
|
129
129
|
"devalue": "^5.0.0",
|
|
130
130
|
"eslint": "^9.13.0",
|
|
131
|
-
"express": "^
|
|
131
|
+
"express": "^5.0.0",
|
|
132
132
|
"fastify": "^4.16.0",
|
|
133
133
|
"fastify-plugin": "^5.0.0",
|
|
134
134
|
"hash-sum": "^2.0.0",
|
|
135
135
|
"myzod": "^1.3.1",
|
|
136
|
-
"next": "^15.
|
|
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.
|
|
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.
|
|
153
|
+
"typescript": ">=5.7.2"
|
|
154
154
|
},
|
|
155
|
-
"gitHead": "
|
|
155
|
+
"gitHead": "ce45f1c48b24261580aabe1793a78876d77e5168"
|
|
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
|
|
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,23 @@
|
|
|
1
1
|
import type * as http from 'http';
|
|
2
2
|
import { TRPCError } from '../../@trpc/server';
|
|
3
3
|
|
|
4
|
-
export interface
|
|
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
|
+
* The socket object provided in the request does not fully implement the expected Node.js Socket interface.
|
|
14
|
+
* @see https://github.com/trpc/trpc/pull/6358
|
|
15
|
+
*/
|
|
16
|
+
socket?: Partial<http.IncomingMessage['socket']>;
|
|
9
17
|
}
|
|
10
18
|
|
|
11
19
|
function createBody(
|
|
12
|
-
req:
|
|
20
|
+
req: UniversalIncomingMessage,
|
|
13
21
|
opts: {
|
|
14
22
|
/**
|
|
15
23
|
* Max body size in bytes. If the body is larger than this, the request will be aborted
|
|
@@ -19,16 +27,16 @@ function createBody(
|
|
|
19
27
|
): RequestInit['body'] {
|
|
20
28
|
// Some adapters will pre-parse the body and add it to the request object
|
|
21
29
|
if ('body' in req) {
|
|
30
|
+
if (req.body === undefined) {
|
|
31
|
+
// If body property exists but is undefined, return undefined
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
22
34
|
// If the body is already a string, return it directly
|
|
23
35
|
if (typeof req.body === 'string') {
|
|
24
36
|
return req.body;
|
|
25
37
|
}
|
|
26
38
|
// If body exists but isn't a string, stringify it as JSON
|
|
27
|
-
|
|
28
|
-
return JSON.stringify(req.body);
|
|
29
|
-
}
|
|
30
|
-
// If body property exists but is undefined, return undefined
|
|
31
|
-
return undefined;
|
|
39
|
+
return JSON.stringify(req.body);
|
|
32
40
|
}
|
|
33
41
|
let size = 0;
|
|
34
42
|
let hasClosed = false;
|
|
@@ -71,7 +79,7 @@ function createBody(
|
|
|
71
79
|
},
|
|
72
80
|
});
|
|
73
81
|
}
|
|
74
|
-
export function createURL(req:
|
|
82
|
+
export function createURL(req: UniversalIncomingMessage): URL {
|
|
75
83
|
try {
|
|
76
84
|
const protocol =
|
|
77
85
|
req.socket && 'encrypted' in req.socket && req.socket.encrypted
|
|
@@ -117,7 +125,7 @@ function createHeaders(incoming: http.IncomingHttpHeaders): Headers {
|
|
|
117
125
|
* 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
126
|
*/
|
|
119
127
|
export function incomingMessageToRequest(
|
|
120
|
-
req:
|
|
128
|
+
req: UniversalIncomingMessage,
|
|
121
129
|
res: http.ServerResponse,
|
|
122
130
|
opts: {
|
|
123
131
|
/**
|
|
@@ -130,14 +138,14 @@ export function incomingMessageToRequest(
|
|
|
130
138
|
|
|
131
139
|
const onAbort = () => {
|
|
132
140
|
res.off('close', onAbort);
|
|
133
|
-
req.socket
|
|
141
|
+
req.socket?.off?.('end', onAbort);
|
|
134
142
|
|
|
135
143
|
// abort the request
|
|
136
144
|
ac.abort();
|
|
137
145
|
};
|
|
138
146
|
|
|
139
147
|
res.once('close', onAbort);
|
|
140
|
-
req.socket
|
|
148
|
+
req.socket?.once?.('end', onAbort);
|
|
141
149
|
|
|
142
150
|
// Get host from either regular header or HTTP/2 pseudo-header
|
|
143
151
|
const url = createURL(req);
|
|
@@ -70,11 +70,12 @@ export const createRecursiveProxy = <TFaux = unknown>(
|
|
|
70
70
|
* @internal
|
|
71
71
|
*/
|
|
72
72
|
export const createFlatProxy = <TFaux>(
|
|
73
|
-
callback: (path: string & keyof TFaux) => any,
|
|
73
|
+
callback: (path: (string & keyof TFaux) | symbol) => any,
|
|
74
74
|
): TFaux => {
|
|
75
75
|
return new Proxy(noop, {
|
|
76
76
|
get(_obj, name) {
|
|
77
|
-
|
|
77
|
+
const type = typeof name;
|
|
78
|
+
if ((type !== 'string' && type !== 'symbol') || name === 'then') {
|
|
78
79
|
// special case for if the proxy is accidentally treated
|
|
79
80
|
// like a PromiseLike (like in `Promise.resolve(proxy)`)
|
|
80
81
|
return undefined;
|
|
@@ -176,27 +176,30 @@ export function sseStreamProducer<TValue = unknown>(
|
|
|
176
176
|
};
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
+
|
|
179
180
|
const stream = readableStreamFrom(generatorWithErrorHandling());
|
|
180
181
|
|
|
181
|
-
return stream
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
182
|
+
return stream
|
|
183
|
+
.pipeThrough(
|
|
184
|
+
new TransformStream({
|
|
185
|
+
transform(chunk, controller: TransformStreamDefaultController<string>) {
|
|
186
|
+
if ('event' in chunk) {
|
|
187
|
+
controller.enqueue(`event: ${chunk.event}\n`);
|
|
188
|
+
}
|
|
189
|
+
if ('data' in chunk) {
|
|
190
|
+
controller.enqueue(`data: ${chunk.data}\n`);
|
|
191
|
+
}
|
|
192
|
+
if ('id' in chunk) {
|
|
193
|
+
controller.enqueue(`id: ${chunk.id}\n`);
|
|
194
|
+
}
|
|
195
|
+
if ('comment' in chunk) {
|
|
196
|
+
controller.enqueue(`: ${chunk.comment}\n`);
|
|
197
|
+
}
|
|
198
|
+
controller.enqueue('\n\n');
|
|
199
|
+
},
|
|
200
|
+
}),
|
|
201
|
+
)
|
|
202
|
+
.pipeThrough(new TextEncoderStream());
|
|
200
203
|
}
|
|
201
204
|
|
|
202
205
|
interface ConsumerStreamResultBase<TConfig extends ConsumerConfig> {
|
|
@@ -361,8 +364,12 @@ export function sseStreamConsumer<TConfig extends ConsumerConfig>(
|
|
|
361
364
|
});
|
|
362
365
|
|
|
363
366
|
const onAbort = () => {
|
|
364
|
-
|
|
365
|
-
|
|
367
|
+
try {
|
|
368
|
+
eventSource.close();
|
|
369
|
+
controller.close();
|
|
370
|
+
} catch {
|
|
371
|
+
// ignore errors in case the controller is already closed
|
|
372
|
+
}
|
|
366
373
|
};
|
|
367
374
|
if (signal.aborted) {
|
|
368
375
|
onAbort();
|