@trpc/server 11.0.0-rc.370 → 11.0.0-rc.373

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.
@@ -8,27 +8,29 @@ require('../../unstable-core-do-not-import/rootConfig.js');
8
8
  */ function incomingMessageToBodyStream(req, opts) {
9
9
  let size = 0;
10
10
  const maxBodySize = opts.maxBodySize;
11
- let controller = null;
11
+ let hasClosed = false;
12
12
  const stream = new ReadableStream({
13
- start (c) {
14
- controller = c;
15
- },
16
- async pull (c) {
17
- const chunk = req.read();
18
- if (chunk) {
13
+ start (controller) {
14
+ req.on('data', (chunk)=>{
19
15
  size += chunk.length;
20
- }
21
- if (maxBodySize !== null && size > maxBodySize) {
22
- controller.error(new TRPCError.TRPCError({
23
- code: 'PAYLOAD_TOO_LARGE'
24
- }));
25
- return;
26
- }
27
- if (chunk === null) {
28
- c.close();
29
- return;
30
- }
31
- controller.enqueue(chunk);
16
+ if (maxBodySize != null && size > maxBodySize) {
17
+ controller.error(new TRPCError.TRPCError({
18
+ code: 'PAYLOAD_TOO_LARGE'
19
+ }));
20
+ // an error is thrown if we try to close the controller after
21
+ // erroring, so track the closure
22
+ hasClosed = true;
23
+ return;
24
+ }
25
+ controller.enqueue(chunk);
26
+ });
27
+ req.once('end', ()=>{
28
+ if (hasClosed) {
29
+ return;
30
+ }
31
+ hasClosed = true;
32
+ controller.close();
33
+ });
32
34
  },
33
35
  cancel () {
34
36
  req.destroy();
@@ -6,27 +6,29 @@ import '../../unstable-core-do-not-import/rootConfig.mjs';
6
6
  */ function incomingMessageToBodyStream(req, opts) {
7
7
  let size = 0;
8
8
  const maxBodySize = opts.maxBodySize;
9
- let controller = null;
9
+ let hasClosed = false;
10
10
  const stream = new ReadableStream({
11
- start (c) {
12
- controller = c;
13
- },
14
- async pull (c) {
15
- const chunk = req.read();
16
- if (chunk) {
11
+ start (controller) {
12
+ req.on('data', (chunk)=>{
17
13
  size += chunk.length;
18
- }
19
- if (maxBodySize !== null && size > maxBodySize) {
20
- controller.error(new TRPCError({
21
- code: 'PAYLOAD_TOO_LARGE'
22
- }));
23
- return;
24
- }
25
- if (chunk === null) {
26
- c.close();
27
- return;
28
- }
29
- controller.enqueue(chunk);
14
+ if (maxBodySize != null && size > maxBodySize) {
15
+ controller.error(new TRPCError({
16
+ code: 'PAYLOAD_TOO_LARGE'
17
+ }));
18
+ // an error is thrown if we try to close the controller after
19
+ // erroring, so track the closure
20
+ hasClosed = true;
21
+ return;
22
+ }
23
+ controller.enqueue(chunk);
24
+ });
25
+ req.once('end', ()=>{
26
+ if (hasClosed) {
27
+ return;
28
+ }
29
+ hasClosed = true;
30
+ controller.close();
31
+ });
30
32
  },
31
33
  cancel () {
32
34
  req.destroy();
@@ -1,7 +1,7 @@
1
1
  {
2
- "bundleSize": 86976,
3
- "bundleOrigSize": 134089,
4
- "bundleReduction": 35.14,
2
+ "bundleSize": 87199,
3
+ "bundleOrigSize": 134166,
4
+ "bundleReduction": 35.01,
5
5
  "modules": [
6
6
  {
7
7
  "id": "/src/adapters/ws.ts",
@@ -15,7 +15,7 @@
15
15
  "dependents": [
16
16
  "/src/adapters/fastify/fastifyTRPCPlugin.ts"
17
17
  ],
18
- "percent": 12.92,
18
+ "percent": 12.89,
19
19
  "reduction": 0
20
20
  },
21
21
  {
@@ -29,7 +29,7 @@
29
29
  "dependents": [
30
30
  "/src/unstable-core-do-not-import.ts"
31
31
  ],
32
- "percent": 10.91,
32
+ "percent": 10.89,
33
33
  "reduction": 4.97
34
34
  },
35
35
  {
@@ -44,7 +44,7 @@
44
44
  "/src/unstable-core-do-not-import.ts",
45
45
  "/src/unstable-core-do-not-import/initTRPC.ts"
46
46
  ],
47
- "percent": 7.27,
47
+ "percent": 7.25,
48
48
  "reduction": 59.52
49
49
  },
50
50
  {
@@ -63,7 +63,7 @@
63
63
  "/src/unstable-core-do-not-import/http/resolveResponse.ts",
64
64
  "/src/unstable-core-do-not-import/initTRPC.ts"
65
65
  ],
66
- "percent": 6.88,
66
+ "percent": 6.87,
67
67
  "reduction": 41.05
68
68
  },
69
69
  {
@@ -78,7 +78,7 @@
78
78
  "/src/unstable-core-do-not-import.ts",
79
79
  "/src/unstable-core-do-not-import/http/resolveResponse.ts"
80
80
  ],
81
- "percent": 6.38,
81
+ "percent": 6.36,
82
82
  "reduction": 0
83
83
  },
84
84
  {
@@ -92,7 +92,7 @@
92
92
  "dependents": [
93
93
  "/src/adapters/aws-lambda/index.ts"
94
94
  ],
95
- "percent": 5.58,
95
+ "percent": 5.56,
96
96
  "reduction": 13.62
97
97
  },
98
98
  {
@@ -109,7 +109,7 @@
109
109
  "/src/observable/index.ts",
110
110
  "/src/observable/operators.ts"
111
111
  ],
112
- "percent": 3.6,
112
+ "percent": 3.59,
113
113
  "reduction": 0.67
114
114
  },
115
115
  {
@@ -123,7 +123,7 @@
123
123
  "dependents": [
124
124
  "/src/adapters/next-app-dir.ts"
125
125
  ],
126
- "percent": 3.51,
126
+ "percent": 3.5,
127
127
  "reduction": 20.12
128
128
  },
129
129
  {
@@ -139,7 +139,7 @@
139
139
  "dependents": [
140
140
  "/src/observable/index.ts"
141
141
  ],
142
- "percent": 3.17,
142
+ "percent": 3.16,
143
143
  "reduction": 0
144
144
  },
145
145
  {
@@ -173,7 +173,7 @@
173
173
  "dependents": [
174
174
  "/src/unstable-core-do-not-import.ts"
175
175
  ],
176
- "percent": 3.05,
176
+ "percent": 3.04,
177
177
  "reduction": 41.46
178
178
  },
179
179
  {
@@ -193,7 +193,7 @@
193
193
  "/src/unstable-core-do-not-import/initTRPC.ts",
194
194
  "/src/unstable-core-do-not-import/procedureBuilder.ts"
195
195
  ],
196
- "percent": 3.02,
196
+ "percent": 3.01,
197
197
  "reduction": 55.5
198
198
  },
199
199
  {
@@ -210,6 +210,21 @@
210
210
  "percent": 2.59,
211
211
  "reduction": 2.17
212
212
  },
213
+ {
214
+ "id": "/src/adapters/node-http/incomingMessageToRequest.ts",
215
+ "size": 2177,
216
+ "origSize": 2535,
217
+ "renderedExports": [
218
+ "incomingMessageToRequest"
219
+ ],
220
+ "removedExports": [],
221
+ "dependents": [
222
+ "/src/adapters/node-http/index.ts",
223
+ "/src/adapters/node-http/nodeHTTPRequestHandler.ts"
224
+ ],
225
+ "percent": 2.5,
226
+ "reduction": 14.12
227
+ },
213
228
  {
214
229
  "id": "/src/unstable-core-do-not-import/createProxy.ts",
215
230
  "size": 2000,
@@ -223,24 +238,9 @@
223
238
  "/src/unstable-core-do-not-import.ts",
224
239
  "/src/unstable-core-do-not-import/router.ts"
225
240
  ],
226
- "percent": 2.3,
241
+ "percent": 2.29,
227
242
  "reduction": 0
228
243
  },
229
- {
230
- "id": "/src/adapters/node-http/incomingMessageToRequest.ts",
231
- "size": 1954,
232
- "origSize": 2458,
233
- "renderedExports": [
234
- "incomingMessageToRequest"
235
- ],
236
- "removedExports": [],
237
- "dependents": [
238
- "/src/adapters/node-http/index.ts",
239
- "/src/adapters/node-http/nodeHTTPRequestHandler.ts"
240
- ],
241
- "percent": 2.25,
242
- "reduction": 20.5
243
- },
244
244
  {
245
245
  "id": "/src/unstable-core-do-not-import/error/TRPCError.ts",
246
246
  "size": 1733,
@@ -273,7 +273,7 @@
273
273
  "dependents": [
274
274
  "/src/adapters/node-http/index.ts"
275
275
  ],
276
- "percent": 1.98,
276
+ "percent": 1.97,
277
277
  "reduction": 20.03
278
278
  },
279
279
  {
@@ -285,7 +285,7 @@
285
285
  ],
286
286
  "removedExports": [],
287
287
  "dependents": [],
288
- "percent": 1.82,
288
+ "percent": 1.81,
289
289
  "reduction": 21.04
290
290
  },
291
291
  {
@@ -341,7 +341,7 @@
341
341
  "/src/unstable-core-do-not-import/http/resolveResponse.ts",
342
342
  "/src/unstable-core-do-not-import/error/getErrorShape.ts"
343
343
  ],
344
- "percent": 1.46,
344
+ "percent": 1.45,
345
345
  "reduction": 23.5
346
346
  },
347
347
  {
@@ -405,11 +405,11 @@
405
405
  "removedExports": [],
406
406
  "dependents": [
407
407
  "/src/unstable-core-do-not-import.ts",
408
+ "/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
408
409
  "/src/unstable-core-do-not-import/error/TRPCError.ts",
409
410
  "/src/unstable-core-do-not-import/router.ts",
410
411
  "/src/unstable-core-do-not-import/transformer.ts",
411
412
  "/src/unstable-core-do-not-import/middleware.ts",
412
- "/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
413
413
  "/src/unstable-core-do-not-import/http/contentType.ts",
414
414
  "/src/unstable-core-do-not-import/procedureBuilder.ts"
415
415
  ],
@@ -454,7 +454,7 @@
454
454
  "/src/unstable-core-do-not-import.ts",
455
455
  "/src/unstable-core-do-not-import/http/resolveResponse.ts"
456
456
  ],
457
- "percent": 0.77,
457
+ "percent": 0.76,
458
458
  "reduction": 0.6
459
459
  },
460
460
  {
@@ -496,7 +496,7 @@
496
496
  "dependents": [
497
497
  "/src/adapters/next-app-dir/nextAppDirCaller.ts"
498
498
  ],
499
- "percent": 0.49,
499
+ "percent": 0.48,
500
500
  "reduction": 40.06
501
501
  },
502
502
  {
@@ -624,9 +624,9 @@
624
624
  "reduction": 100
625
625
  },
626
626
  {
627
- "id": "/src/index.ts",
627
+ "id": "/src/rpc.ts",
628
628
  "size": 0,
629
- "origSize": 32,
629
+ "origSize": 36,
630
630
  "renderedExports": [],
631
631
  "removedExports": [],
632
632
  "dependents": [],
@@ -634,9 +634,9 @@
634
634
  "reduction": 100
635
635
  },
636
636
  {
637
- "id": "/src/rpc.ts",
637
+ "id": "/src/index.ts",
638
638
  "size": 0,
639
- "origSize": 36,
639
+ "origSize": 32,
640
640
  "renderedExports": [],
641
641
  "removedExports": [],
642
642
  "dependents": [],
@@ -644,9 +644,9 @@
644
644
  "reduction": 100
645
645
  },
646
646
  {
647
- "id": "/src/shared.ts",
647
+ "id": "/src/unstable-core-do-not-import.ts",
648
648
  "size": 0,
649
- "origSize": 653,
649
+ "origSize": 1908,
650
650
  "renderedExports": [],
651
651
  "removedExports": [],
652
652
  "dependents": [],
@@ -654,9 +654,9 @@
654
654
  "reduction": 100
655
655
  },
656
656
  {
657
- "id": "/src/unstable-core-do-not-import.ts",
657
+ "id": "/src/shared.ts",
658
658
  "size": 0,
659
- "origSize": 1908,
659
+ "origSize": 653,
660
660
  "renderedExports": [],
661
661
  "removedExports": [],
662
662
  "dependents": [],
@@ -713,8 +713,8 @@
713
713
  "removedExports": [],
714
714
  "dependents": [
715
715
  "/src/adapters/express.ts",
716
- "/src/adapters/standalone.ts",
717
716
  "/src/adapters/next.ts",
717
+ "/src/adapters/standalone.ts",
718
718
  "/src/adapters/fastify/fastifyRequestHandler.ts"
719
719
  ],
720
720
  "percent": 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/server",
3
- "version": "11.0.0-rc.370+1a920ac81",
3
+ "version": "11.0.0-rc.373+db2ec5cae",
4
4
  "description": "The tRPC server library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -149,5 +149,5 @@
149
149
  "funding": [
150
150
  "https://trpc.io/sponsor"
151
151
  ],
152
- "gitHead": "1a920ac8160dacfb6a49e6161f56208859168317"
152
+ "gitHead": "db2ec5cae339cabd8dfa19bdc1d596214568d205"
153
153
  }
@@ -17,32 +17,32 @@ function incomingMessageToBodyStream(
17
17
  type Value = Buffer | Uint8Array | string | null;
18
18
  let size = 0;
19
19
  const maxBodySize = opts.maxBodySize;
20
+ let hasClosed = false;
20
21
 
21
- let controller: ReadableStreamDefaultController<Value> =
22
- null as unknown as ReadableStreamDefaultController<Value>;
23
22
  const stream = new ReadableStream<Value>({
24
- start(c) {
25
- controller = c;
26
- },
27
- async pull(c) {
28
- const chunk: Value = req.read();
29
-
30
- if (chunk) {
23
+ start(controller) {
24
+ req.on('data', (chunk) => {
31
25
  size += chunk.length;
32
- }
33
- if (maxBodySize !== null && size > maxBodySize) {
34
- controller.error(
35
- new TRPCError({
36
- code: 'PAYLOAD_TOO_LARGE',
37
- }),
38
- );
39
- return;
40
- }
41
- if (chunk === null) {
42
- c.close();
43
- return;
44
- }
45
- controller.enqueue(chunk);
26
+ if (maxBodySize != null && size > maxBodySize) {
27
+ controller.error(
28
+ new TRPCError({
29
+ code: 'PAYLOAD_TOO_LARGE',
30
+ }),
31
+ );
32
+ // an error is thrown if we try to close the controller after
33
+ // erroring, so track the closure
34
+ hasClosed = true;
35
+ return;
36
+ }
37
+ controller.enqueue(chunk);
38
+ });
39
+ req.once('end', () => {
40
+ if (hasClosed) {
41
+ return;
42
+ }
43
+ hasClosed = true;
44
+ controller.close();
45
+ });
46
46
  },
47
47
  cancel() {
48
48
  req.destroy();