@trpc/server 11.23.1-canary.41.02769648b → 11.24.0

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.
Files changed (47) hide show
  1. package/dist/adapters/express.cjs +1 -1
  2. package/dist/adapters/express.mjs +1 -1
  3. package/dist/adapters/fastify/index.cjs +4 -3
  4. package/dist/adapters/fastify/index.d.cts +9 -1
  5. package/dist/adapters/fastify/index.d.cts.map +1 -1
  6. package/dist/adapters/fastify/index.d.mts +9 -1
  7. package/dist/adapters/fastify/index.d.mts.map +1 -1
  8. package/dist/adapters/fastify/index.mjs +4 -3
  9. package/dist/adapters/fastify/index.mjs.map +1 -1
  10. package/dist/adapters/next.cjs +1 -1
  11. package/dist/adapters/next.mjs +1 -1
  12. package/dist/adapters/node-http/index.cjs +1 -1
  13. package/dist/adapters/node-http/index.mjs +1 -1
  14. package/dist/adapters/standalone.cjs +1 -1
  15. package/dist/adapters/standalone.mjs +1 -1
  16. package/dist/adapters/ws.cjs +1 -1
  17. package/dist/adapters/ws.mjs +1 -1
  18. package/dist/{node-http-BmySCIg9.mjs → node-http-BHs4hFcB.mjs} +12 -12
  19. package/dist/node-http-BHs4hFcB.mjs.map +1 -0
  20. package/dist/{node-http-BDK8soAL.cjs → node-http-fnRXnfX7.cjs} +11 -11
  21. package/dist/{ws-BfbxiUMK.mjs → ws-BY66ccWn.mjs} +43 -5
  22. package/dist/{ws-BfbxiUMK.mjs.map → ws-BY66ccWn.mjs.map} +1 -1
  23. package/dist/ws-C6aokjeu.d.cts.map +1 -1
  24. package/dist/ws-CA_yykwZ.d.mts.map +1 -1
  25. package/dist/{ws-DotSgEee.cjs → ws-D8h4AHV-.cjs} +42 -4
  26. package/package.json +2 -2
  27. package/skills/adapter-aws-lambda/SKILL.md +11 -3
  28. package/skills/adapter-express/SKILL.md +11 -3
  29. package/skills/adapter-fastify/SKILL.md +11 -3
  30. package/skills/adapter-fetch/SKILL.md +1 -1
  31. package/skills/adapter-standalone/SKILL.md +11 -3
  32. package/skills/auth/SKILL.md +1 -1
  33. package/skills/caching/SKILL.md +1 -1
  34. package/skills/error-handling/SKILL.md +1 -1
  35. package/skills/middlewares/SKILL.md +1 -1
  36. package/skills/non-json-content-types/SKILL.md +1 -1
  37. package/skills/server-setup/SKILL.md +1 -1
  38. package/skills/server-side-calls/SKILL.md +1 -1
  39. package/skills/service-oriented-architecture/SKILL.md +1 -1
  40. package/skills/subscriptions/SKILL.md +1 -1
  41. package/skills/subscriptions/references/server-websockets.md +30 -0
  42. package/skills/trpc-router/SKILL.md +1 -1
  43. package/skills/validators/SKILL.md +1 -1
  44. package/src/adapters/fastify/fastifyRequestHandler.ts +10 -3
  45. package/src/adapters/node-http/incomingMessageToRequest.ts +14 -14
  46. package/src/adapters/ws.ts +50 -0
  47. package/dist/node-http-BmySCIg9.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ws-CA_yykwZ.d.mts","names":[],"sources":["../src/adapters/ws.ts"],"mappings":";;;;;;;;;;;;KAyDY,4BAA4B,+BACtC,iBACA;;;;;KAOU,mBAAmB,gBAAgB,cAC7C,MAAM,8BACH,aAAa,mBAAmB;;KAGzB,2BAA2B,gBAAgB,aACrD,mBAAmB,SAAS,mBAC1B,sBACE,mBAAmB,UACnB,mBAAmB;;;;;KAOb,kBAAkB,gBAAgB,aAC5C,2BAA2B;;EAEzB,KAAK;;EAEL;;;;;EAKA;;;;;IAKE;;;;;IAKA;;;;;;IAMA;;;;;;EAMF;;;;;;EAMA,uBAAuB;;;;;;iBAOX,uBAAuB,gBAAgB,WACrD,MAAM,kBAAkB,YAAQ,QAMhB,WAAW,KAAO;;;;;iBA6cpB,gBACd,QAAQ,WACR,iBACA;;;;;;;;;;;;;;;;iBAkDc,gBAAgB,gBAAgB,WAC9C,MAAM,kBAAkB;EAatB"}
1
+ {"version":3,"file":"ws-CA_yykwZ.d.mts","names":[],"sources":["../src/adapters/ws.ts"],"mappings":";;;;;;;;;;;;KAyDY,4BAA4B,+BACtC,iBACA;;;;;KAOU,mBAAmB,gBAAgB,cAC7C,MAAM,8BACH,aAAa,mBAAmB;;KAGzB,2BAA2B,gBAAgB,aACrD,mBAAmB,SAAS,mBAC1B,sBACE,mBAAmB,UACnB,mBAAmB;;;;;KAOb,kBAAkB,gBAAgB,aAC5C,2BAA2B;;EAEzB,KAAK;;EAEL;;;;;EAKA;;;;;IAKE;;;;;IAKA;;;;;;IAMA;;;;;;EAMF;;;;;;EAMA,uBAAuB;;;;;;iBAOX,uBAAuB,gBAAgB,WACrD,MAAM,kBAAkB,YAAQ,QAMhB,WAAW,KAAO;;;;;iBA+fpB,gBACd,QAAQ,WACR,iBACA;;;;;;;;;;;;;;;;iBAkDc,gBAAgB,gBAAgB,WAC9C,MAAM,kBAAkB;EAatB"}
@@ -4,7 +4,7 @@ const require_parseTRPCMessage = require("./parseTRPCMessage-BsPr5reh.cjs");
4
4
  const require_asyncGeneratorDelegate = require("./asyncGeneratorDelegate-CMdmcplC.cjs");
5
5
  const require_resolveResponse = require("./resolveResponse-BLSF4Ks0.cjs");
6
6
  const require_observable = require("./observable-B8nn0anr.cjs");
7
- const require_node_http = require("./node-http-BDK8soAL.cjs");
7
+ const require_node_http = require("./node-http-fnRXnfX7.cjs");
8
8
  //#region src/adapters/wsEncoder.ts
9
9
  /**
10
10
  * The default encoder: JSON in text frames.
@@ -367,7 +367,45 @@ function getWSConnectionHandler(opts) {
367
367
  require_codes.run(() => {
368
368
  try {
369
369
  const msgJSON = encoder.decode(data);
370
- return (Array.isArray(msgJSON) ? msgJSON : [msgJSON]).map((raw) => require_parseTRPCMessage.parseTRPCMessage(raw, transformer));
370
+ const msgs = Array.isArray(msgJSON) ? msgJSON : [msgJSON];
371
+ if (Array.isArray(msgJSON) && typeof opts.maxBatchSize === "number" && msgs.length > opts.maxBatchSize) {
372
+ var _opts$onError6;
373
+ const error = new require_asyncGeneratorDelegate.TRPCError({
374
+ code: "BAD_REQUEST",
375
+ message: `Batch call exceeds maximum size`
376
+ });
377
+ (_opts$onError6 = opts.onError) === null || _opts$onError6 === void 0 || _opts$onError6.call(opts, {
378
+ error,
379
+ path: void 0,
380
+ type: "unknown",
381
+ ctx,
382
+ req,
383
+ input: void 0
384
+ });
385
+ const errorShape = require_getErrorShape.getErrorShape({
386
+ config: router._def._config,
387
+ error,
388
+ type: "unknown",
389
+ path: void 0,
390
+ input: void 0,
391
+ ctx
392
+ });
393
+ let responded = false;
394
+ for (const raw of msgs) if (require_codes.isObject(raw) && raw["method"] !== "subscription.stop" && (typeof raw["id"] === "number" || typeof raw["id"] === "string")) {
395
+ respond({
396
+ id: raw["id"],
397
+ jsonrpc: raw["jsonrpc"] === "2.0" ? "2.0" : void 0,
398
+ error: errorShape
399
+ });
400
+ responded = true;
401
+ }
402
+ if (!responded) respond({
403
+ id: null,
404
+ error: errorShape
405
+ });
406
+ return [];
407
+ }
408
+ return msgs.map((raw) => require_parseTRPCMessage.parseTRPCMessage(raw, transformer));
371
409
  } catch (cause) {
372
410
  const error = new require_asyncGeneratorDelegate.TRPCError({
373
411
  code: "PARSE_ERROR",
@@ -389,8 +427,8 @@ function getWSConnectionHandler(opts) {
389
427
  }).map((msg, index) => handleRequest(msg, index));
390
428
  });
391
429
  client.on("error", (cause) => {
392
- var _opts$onError6;
393
- (_opts$onError6 = opts.onError) === null || _opts$onError6 === void 0 || _opts$onError6.call(opts, {
430
+ var _opts$onError7;
431
+ (_opts$onError7 = opts.onError) === null || _opts$onError7 === void 0 || _opts$onError7.call(opts, {
394
432
  ctx,
395
433
  error: require_asyncGeneratorDelegate.getTRPCErrorFromUnknown(cause),
396
434
  input: void 0,
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@trpc/server",
3
3
  "type": "module",
4
4
  "sideEffects": false,
5
- "version": "11.23.1-canary.41.02769648b",
5
+ "version": "11.24.0",
6
6
  "description": "The tRPC server library",
7
7
  "author": "KATT",
8
8
  "license": "MIT",
@@ -257,5 +257,5 @@
257
257
  "keywords": [
258
258
  "tanstack-intent"
259
259
  ],
260
- "gitHead": "02769648bfa3c00388737ebf430aed80ced03bb3"
260
+ "gitHead": "b147c52e0a6af43a8d735d24bc3d5ef6c7cd42ed"
261
261
  }
@@ -9,7 +9,7 @@ sources:
9
9
  metadata:
10
10
  type: core
11
11
  library: trpc
12
- library_version: 11.23.1-canary.41.02769648b
12
+ library_version: 11.24.0
13
13
  ---
14
14
 
15
15
  <!-- Generated from www/v11/docs/server/adapters/aws-lambda.md by www/build/skills.ts. Edit the docs instead. -->
@@ -196,7 +196,7 @@ Every HTTP adapter accepts these options, next to its own (like `endpoint` for F
196
196
 
197
197
  The Node.js adapters (Standalone, Express and Next.js) also accept:
198
198
 
199
- - `maxBodySize`: the largest request body in bytes; larger ones are rejected with `413 PAYLOAD_TOO_LARGE`.
199
+ - `maxBodySize`: the largest request body in bytes; larger ones are rejected with `413 PAYLOAD_TOO_LARGE`. There's no limit by default; see [Request body size](https://trpc.io/docs/server/adapters#request-body-size).
200
200
  - `middleware`: a connect-style `(req, res, next)` function that runs before tRPC, e.g. [`cors()`](https://trpc.io/docs/server/adapters/standalone#handling-cors--options).
201
201
 
202
202
  ```ts no-check title="server.ts"
@@ -210,10 +210,18 @@ createHTTPServer({
210
210
  console.error(`tRPC error on '${path}':`, error);
211
211
  },
212
212
  maxBatchSize: 10,
213
- maxBodySize: 1_000_000, // 1 MB
213
+ maxBodySize: 1024 * 1024, // 1 MiB
214
214
  }).listen(3000);
215
215
  ```
216
216
 
217
+ ### Request body size
218
+
219
+ The Node.js adapters read the request body into memory, and `maxBodySize` is unset by default, so they accept bodies of any size. On a server that's reachable from the internet, set `maxBodySize` so a single large request can't exhaust the process's memory. A body over the limit is rejected with `413 PAYLOAD_TOO_LARGE` as soon as it passes the limit, before it's parsed.
220
+
221
+ We recommend `1024 * 1024` (1 MiB) for typical JSON inputs, as in the example above. If you accept files or other large inputs, set it a little above the largest one you expect, and keep it under about `10 * 1024 * 1024` (10 MiB).
222
+
223
+ `maxBodySize` only applies to bodies tRPC reads itself. If a body parser such as `express.json()` or the Next.js API routes body parser has already set `req.body`, limit the size in that parser instead. A limit in your reverse proxy (like nginx's `client_max_body_size`) adds another layer.
224
+
217
225
  From https://trpc.io/docs/server/adapters#common-options
218
226
 
219
227
  ## Related skills
@@ -9,7 +9,7 @@ sources:
9
9
  metadata:
10
10
  type: core
11
11
  library: trpc
12
- library_version: 11.23.1-canary.41.02769648b
12
+ library_version: 11.24.0
13
13
  ---
14
14
 
15
15
  <!-- Generated from www/v11/docs/server/adapters/express.md by www/build/skills.ts. Edit the docs instead. -->
@@ -165,7 +165,7 @@ Every HTTP adapter accepts these options, next to its own (like `endpoint` for F
165
165
 
166
166
  The Node.js adapters (Standalone, Express and Next.js) also accept:
167
167
 
168
- - `maxBodySize`: the largest request body in bytes; larger ones are rejected with `413 PAYLOAD_TOO_LARGE`.
168
+ - `maxBodySize`: the largest request body in bytes; larger ones are rejected with `413 PAYLOAD_TOO_LARGE`. There's no limit by default; see [Request body size](https://trpc.io/docs/server/adapters#request-body-size).
169
169
  - `middleware`: a connect-style `(req, res, next)` function that runs before tRPC, e.g. [`cors()`](https://trpc.io/docs/server/adapters/standalone#handling-cors--options).
170
170
 
171
171
  ```ts no-check title="server.ts"
@@ -179,10 +179,18 @@ createHTTPServer({
179
179
  console.error(`tRPC error on '${path}':`, error);
180
180
  },
181
181
  maxBatchSize: 10,
182
- maxBodySize: 1_000_000, // 1 MB
182
+ maxBodySize: 1024 * 1024, // 1 MiB
183
183
  }).listen(3000);
184
184
  ```
185
185
 
186
+ ### Request body size
187
+
188
+ The Node.js adapters read the request body into memory, and `maxBodySize` is unset by default, so they accept bodies of any size. On a server that's reachable from the internet, set `maxBodySize` so a single large request can't exhaust the process's memory. A body over the limit is rejected with `413 PAYLOAD_TOO_LARGE` as soon as it passes the limit, before it's parsed.
189
+
190
+ We recommend `1024 * 1024` (1 MiB) for typical JSON inputs, as in the example above. If you accept files or other large inputs, set it a little above the largest one you expect, and keep it under about `10 * 1024 * 1024` (10 MiB).
191
+
192
+ `maxBodySize` only applies to bodies tRPC reads itself. If a body parser such as `express.json()` or the Next.js API routes body parser has already set `req.body`, limit the size in that parser instead. A limit in your reverse proxy (like nginx's `client_max_body_size`) adds another layer.
193
+
186
194
  From https://trpc.io/docs/server/adapters#common-options
187
195
 
188
196
  ## Related skills
@@ -9,7 +9,7 @@ sources:
9
9
  metadata:
10
10
  type: core
11
11
  library: trpc
12
- library_version: 11.23.1-canary.41.02769648b
12
+ library_version: 11.24.0
13
13
  ---
14
14
 
15
15
  <!-- Generated from www/v11/docs/server/adapters/fastify.md by www/build/skills.ts. Edit the docs instead. -->
@@ -288,7 +288,7 @@ Every HTTP adapter accepts these options, next to its own (like `endpoint` for F
288
288
 
289
289
  The Node.js adapters (Standalone, Express and Next.js) also accept:
290
290
 
291
- - `maxBodySize`: the largest request body in bytes; larger ones are rejected with `413 PAYLOAD_TOO_LARGE`.
291
+ - `maxBodySize`: the largest request body in bytes; larger ones are rejected with `413 PAYLOAD_TOO_LARGE`. There's no limit by default; see [Request body size](https://trpc.io/docs/server/adapters#request-body-size).
292
292
  - `middleware`: a connect-style `(req, res, next)` function that runs before tRPC, e.g. [`cors()`](https://trpc.io/docs/server/adapters/standalone#handling-cors--options).
293
293
 
294
294
  ```ts no-check title="server.ts"
@@ -302,10 +302,18 @@ createHTTPServer({
302
302
  console.error(`tRPC error on '${path}':`, error);
303
303
  },
304
304
  maxBatchSize: 10,
305
- maxBodySize: 1_000_000, // 1 MB
305
+ maxBodySize: 1024 * 1024, // 1 MiB
306
306
  }).listen(3000);
307
307
  ```
308
308
 
309
+ ### Request body size
310
+
311
+ The Node.js adapters read the request body into memory, and `maxBodySize` is unset by default, so they accept bodies of any size. On a server that's reachable from the internet, set `maxBodySize` so a single large request can't exhaust the process's memory. A body over the limit is rejected with `413 PAYLOAD_TOO_LARGE` as soon as it passes the limit, before it's parsed.
312
+
313
+ We recommend `1024 * 1024` (1 MiB) for typical JSON inputs, as in the example above. If you accept files or other large inputs, set it a little above the largest one you expect, and keep it under about `10 * 1024 * 1024` (10 MiB).
314
+
315
+ `maxBodySize` only applies to bodies tRPC reads itself. If a body parser such as `express.json()` or the Next.js API routes body parser has already set `req.body`, limit the size in that parser instead. A limit in your reverse proxy (like nginx's `client_max_body_size`) adds another layer.
316
+
309
317
  From https://trpc.io/docs/server/adapters#common-options
310
318
 
311
319
  ## Related skills
@@ -8,7 +8,7 @@ sources:
8
8
  metadata:
9
9
  type: core
10
10
  library: trpc
11
- library_version: 11.23.1-canary.41.02769648b
11
+ library_version: 11.24.0
12
12
  ---
13
13
 
14
14
  <!-- Generated from www/v11/docs/server/adapters/fetch.md by www/build/skills.ts. Edit the docs instead. -->
@@ -9,7 +9,7 @@ sources:
9
9
  metadata:
10
10
  type: core
11
11
  library: trpc
12
- library_version: 11.23.1-canary.41.02769648b
12
+ library_version: 11.24.0
13
13
  ---
14
14
 
15
15
  <!-- Generated from www/v11/docs/server/adapters/standalone.md by www/build/skills.ts. Edit the docs instead. -->
@@ -263,7 +263,7 @@ Every HTTP adapter accepts these options, next to its own (like `endpoint` for F
263
263
 
264
264
  The Node.js adapters (Standalone, Express and Next.js) also accept:
265
265
 
266
- - `maxBodySize`: the largest request body in bytes; larger ones are rejected with `413 PAYLOAD_TOO_LARGE`.
266
+ - `maxBodySize`: the largest request body in bytes; larger ones are rejected with `413 PAYLOAD_TOO_LARGE`. There's no limit by default; see [Request body size](https://trpc.io/docs/server/adapters#request-body-size).
267
267
  - `middleware`: a connect-style `(req, res, next)` function that runs before tRPC, e.g. [`cors()`](https://trpc.io/docs/server/adapters/standalone#handling-cors--options).
268
268
 
269
269
  ```ts no-check title="server.ts"
@@ -277,10 +277,18 @@ createHTTPServer({
277
277
  console.error(`tRPC error on '${path}':`, error);
278
278
  },
279
279
  maxBatchSize: 10,
280
- maxBodySize: 1_000_000, // 1 MB
280
+ maxBodySize: 1024 * 1024, // 1 MiB
281
281
  }).listen(3000);
282
282
  ```
283
283
 
284
+ ### Request body size
285
+
286
+ The Node.js adapters read the request body into memory, and `maxBodySize` is unset by default, so they accept bodies of any size. On a server that's reachable from the internet, set `maxBodySize` so a single large request can't exhaust the process's memory. A body over the limit is rejected with `413 PAYLOAD_TOO_LARGE` as soon as it passes the limit, before it's parsed.
287
+
288
+ We recommend `1024 * 1024` (1 MiB) for typical JSON inputs, as in the example above. If you accept files or other large inputs, set it a little above the largest one you expect, and keep it under about `10 * 1024 * 1024` (10 MiB).
289
+
290
+ `maxBodySize` only applies to bodies tRPC reads itself. If a body parser such as `express.json()` or the Next.js API routes body parser has already set `req.body`, limit the size in that parser instead. A limit in your reverse proxy (like nginx's `client_max_body_size`) adds another layer.
291
+
284
292
  From https://trpc.io/docs/server/adapters#common-options
285
293
 
286
294
  ## Related skills
@@ -14,7 +14,7 @@ sources:
14
14
  metadata:
15
15
  type: composition
16
16
  library: trpc
17
- library_version: 11.23.1-canary.41.02769648b
17
+ library_version: 11.24.0
18
18
  ---
19
19
 
20
20
  <!-- Generated from www/v11/docs/server/authorization.md by www/build/skills.ts. Edit the docs instead. -->
@@ -8,7 +8,7 @@ sources:
8
8
  metadata:
9
9
  type: core
10
10
  library: trpc
11
- library_version: 11.23.1-canary.41.02769648b
11
+ library_version: 11.24.0
12
12
  ---
13
13
 
14
14
  <!-- Generated from www/v11/docs/server/caching.md by www/build/skills.ts. Edit the docs instead. -->
@@ -9,7 +9,7 @@ sources:
9
9
  metadata:
10
10
  type: core
11
11
  library: trpc
12
- library_version: 11.23.1-canary.41.02769648b
12
+ library_version: 11.24.0
13
13
  ---
14
14
 
15
15
  <!-- Generated from www/v11/docs/server/error-handling.md by www/build/skills.ts. Edit the docs instead. -->
@@ -8,7 +8,7 @@ sources:
8
8
  metadata:
9
9
  type: core
10
10
  library: trpc
11
- library_version: 11.23.1-canary.41.02769648b
11
+ library_version: 11.24.0
12
12
  ---
13
13
 
14
14
  <!-- Generated from www/v11/docs/server/middlewares.md by www/build/skills.ts. Edit the docs instead. -->
@@ -10,7 +10,7 @@ sources:
10
10
  metadata:
11
11
  type: core
12
12
  library: trpc
13
- library_version: 11.23.1-canary.41.02769648b
13
+ library_version: 11.24.0
14
14
  ---
15
15
 
16
16
  <!-- Generated from www/v11/docs/server/non-json-content-types.md by www/build/skills.ts. Edit the docs instead. -->
@@ -11,7 +11,7 @@ sources:
11
11
  metadata:
12
12
  type: core
13
13
  library: trpc
14
- library_version: 11.23.1-canary.41.02769648b
14
+ library_version: 11.24.0
15
15
  ---
16
16
 
17
17
  <!-- Generated from www/v11/docs/server/overview.md by www/build/skills.ts. Edit the docs instead. -->
@@ -8,7 +8,7 @@ sources:
8
8
  metadata:
9
9
  type: core
10
10
  library: trpc
11
- library_version: 11.23.1-canary.41.02769648b
11
+ library_version: 11.24.0
12
12
  ---
13
13
 
14
14
  <!-- Generated from www/v11/docs/server/server-side-calls.md by www/build/skills.ts. Edit the docs instead. -->
@@ -10,7 +10,7 @@ sources:
10
10
  metadata:
11
11
  type: composition
12
12
  library: trpc
13
- library_version: 11.23.1-canary.41.02769648b
13
+ library_version: 11.24.0
14
14
  ---
15
15
 
16
16
  <!-- Generated from www/v11/docs/server/service-oriented-architecture.md by www/build/skills.ts. Edit the docs instead. -->
@@ -12,7 +12,7 @@ sources:
12
12
  metadata:
13
13
  type: core
14
14
  library: trpc
15
- library_version: 11.23.1-canary.41.02769648b
15
+ library_version: 11.24.0
16
16
  ---
17
17
 
18
18
  <!-- Generated from www/v11/docs/server/subscriptions.md by www/build/skills.ts. Edit the docs instead. -->
@@ -69,6 +69,36 @@ applyWSSHandler({ wss, router: appRouter });
69
69
  server.listen(3000);
70
70
  ```
71
71
 
72
+ ### Limiting batch size
73
+
74
+ `applyWSSHandler` accepts the same `maxBatchSize` option as the [HTTP adapters](https://trpc.io/docs/server/adapters#common-options). A WebSocket message that batches more requests than this is rejected as a whole: no procedure runs, and every request in it, except `subscription.stop` entries, gets a `BAD_REQUEST` error with the message `Batch call exceeds maximum size`.
75
+
76
+ `wsLink` sends all requests made in the same tick as one message and has no `maxItems` option, so pick a limit above the number of calls your client makes at once.
77
+
78
+ ### Rejecting cross-origin connections
79
+
80
+ Browsers don't apply CORS to WebSockets: a page on any origin can open a connection to your server, and the browser sends its cookies with it. If you authenticate with cookies, check the `Origin` header against the origins you trust. With `ws`, do this in `verifyClient`, and pass `403` to its callback so a rejected upgrade gets `403 Forbidden`:
81
+
82
+ ```ts no-check title="server/wsServer.ts"
83
+ import { applyWSSHandler } from '@trpc/server/adapters/ws';
84
+ import { WebSocketServer } from 'ws';
85
+ import { appRouter } from './router';
86
+
87
+ const allowedOrigins = new Set(['https://app.example.com']);
88
+
89
+ const wss = new WebSocketServer({
90
+ port: 3001,
91
+ verifyClient: ({ origin }, callback) => {
92
+ // Browsers always send `Origin`, but other clients may not.
93
+ // Decide whether your app accepts connections without one.
94
+ callback(!origin || allowedOrigins.has(origin), 403);
95
+ },
96
+ });
97
+ applyWSSHandler({ wss, router: appRouter });
98
+ ```
99
+
100
+ If you handle upgrades yourself with `noServer: true`, check `req.headers.origin` in your server's `upgrade` listener instead. For an origin you don't trust, end the socket with a `403` response, such as `socket.end('HTTP/1.1 403 Forbidden\r\nConnection: close\r\n\r\n')`, rather than calling `wss.handleUpgrade()`.
101
+
72
102
  ### Setting `TRPCClient` to use WebSockets
73
103
 
74
104
  > [!TIP]
@@ -7,7 +7,7 @@ sources:
7
7
  metadata:
8
8
  type: core
9
9
  library: trpc
10
- library_version: 11.23.1-canary.41.02769648b
10
+ library_version: 11.24.0
11
11
  ---
12
12
 
13
13
  <!-- Generated from www/v11/docs/skills.md by www/build/skills.ts. Edit the docs instead. -->
@@ -8,7 +8,7 @@ sources:
8
8
  metadata:
9
9
  type: core
10
10
  library: trpc
11
- library_version: 11.23.1-canary.41.02769648b
11
+ library_version: 11.24.0
12
12
  ---
13
13
 
14
14
  <!-- Generated from www/v11/docs/server/validators.md by www/build/skills.ts. Edit the docs instead. -->
@@ -28,8 +28,15 @@ export type FastifyHandlerOptions<
28
28
  TRouter extends AnyRouter,
29
29
  TRequest extends FastifyRequest,
30
30
  TResponse extends FastifyReply,
31
- > = HTTPBaseHandlerOptions<TRouter, TRequest> &
32
- NodeHTTPCreateContextOption<TRouter, TRequest, TResponse>;
31
+ > = HTTPBaseHandlerOptions<TRouter, TRequest> & {
32
+ /**
33
+ * The largest request body, in bytes. A larger one gets a
34
+ * `PAYLOAD_TOO_LARGE` error. It applies to bodies tRPC streams, such as
35
+ * `multipart/form-data`; JSON bodies are read by Fastify, so limit them
36
+ * with Fastify's `bodyLimit`.
37
+ */
38
+ maxBodySize?: number;
39
+ } & NodeHTTPCreateContextOption<TRouter, TRequest, TResponse>;
33
40
 
34
41
  type FastifyRequestHandlerOptions<
35
42
  TRouter extends AnyRouter,
@@ -66,7 +73,7 @@ export async function fastifyRequestHandler<
66
73
  incomingMessage.body = opts.req.body;
67
74
  }
68
75
  const req = incomingMessageToRequest(incomingMessage, opts.res.raw, {
69
- maxBodySize: null,
76
+ maxBodySize: opts.maxBodySize ?? null,
70
77
  });
71
78
 
72
79
  const res = await resolveResponse({
@@ -12,21 +12,21 @@ function createBody(
12
12
  maxBodySize: number | null;
13
13
  },
14
14
  ): RequestInit['body'] {
15
+ let source: NodeHTTPRequest | IncomingMessage = req;
15
16
  // Some adapters will pre-parse the body and add it to the request object
16
17
  if ('body' in req) {
17
- if (req.body !== undefined) {
18
+ if (req.body instanceof IncomingMessage) {
19
+ // An unparsed stream handed over by the adapter (Fastify does this for
20
+ // formData), so read it with the size limit
21
+ source = req.body;
22
+ } else if (req.body !== undefined) {
18
23
  // If the body is already a string, return it directly
19
24
  if (typeof req.body === 'string') {
20
25
  return req.body;
21
26
  }
22
- // formData use
23
- if (req.body instanceof IncomingMessage) {
24
- return req.body as any;
25
- }
26
27
  // If body exists but isn't a string, stringify it as JSON
27
28
  return JSON.stringify(req.body);
28
- }
29
- if (req.readableEnded) {
29
+ } else if (req.readableEnded) {
30
30
  // The stream was consumed without producing a parsed body — there is
31
31
  // nothing left to read
32
32
  return undefined;
@@ -69,8 +69,8 @@ function createBody(
69
69
  }),
70
70
  );
71
71
  hasClosed = true;
72
- req.off('data', onData);
73
- req.off('end', onEnd);
72
+ source.off('data', onData);
73
+ source.off('end', onEnd);
74
74
  };
75
75
 
76
76
  const onEnd = () => {
@@ -78,16 +78,16 @@ function createBody(
78
78
  return;
79
79
  }
80
80
  hasClosed = true;
81
- req.off('data', onData);
82
- req.off('end', onEnd);
81
+ source.off('data', onData);
82
+ source.off('end', onEnd);
83
83
  controller.close();
84
84
  };
85
85
 
86
- req.on('data', onData);
87
- req.on('end', onEnd);
86
+ source.on('data', onData);
87
+ source.on('end', onEnd);
88
88
  },
89
89
  cancel() {
90
- req.destroy();
90
+ source.destroy();
91
91
  },
92
92
  });
93
93
  }
@@ -538,6 +538,56 @@ export function getWSConnectionHandler<TRouter extends AnyRouter>(
538
538
  const msgJSON: unknown = encoder.decode(data);
539
539
  const msgs: unknown[] = Array.isArray(msgJSON) ? msgJSON : [msgJSON];
540
540
 
541
+ if (
542
+ Array.isArray(msgJSON) &&
543
+ typeof opts.maxBatchSize === 'number' &&
544
+ msgs.length > opts.maxBatchSize
545
+ ) {
546
+ const error = new TRPCError({
547
+ code: 'BAD_REQUEST',
548
+ message: `Batch call exceeds maximum size`,
549
+ });
550
+ opts.onError?.({
551
+ error,
552
+ path: undefined,
553
+ type: 'unknown',
554
+ ctx,
555
+ req,
556
+ input: undefined,
557
+ });
558
+ const errorShape = getErrorShape({
559
+ config: router._def._config,
560
+ error,
561
+ type: 'unknown',
562
+ path: undefined,
563
+ input: undefined,
564
+ ctx,
565
+ });
566
+
567
+ // Checked before parsing so that no input is deserialized.
568
+ // Every request in the batch gets the error, as a batched HTTP
569
+ // call does, so that clients do not wait for a response forever.
570
+ let responded = false;
571
+ for (const raw of msgs) {
572
+ if (
573
+ isObject(raw) &&
574
+ raw['method'] !== 'subscription.stop' &&
575
+ (typeof raw['id'] === 'number' || typeof raw['id'] === 'string')
576
+ ) {
577
+ respond({
578
+ id: raw['id'],
579
+ jsonrpc: raw['jsonrpc'] === '2.0' ? '2.0' : undefined,
580
+ error: errorShape,
581
+ });
582
+ responded = true;
583
+ }
584
+ }
585
+ if (!responded) {
586
+ respond({ id: null, error: errorShape });
587
+ }
588
+ return [];
589
+ }
590
+
541
591
  return msgs.map((raw) => parseTRPCMessage(raw, transformer));
542
592
  } catch (cause) {
543
593
  const error = new TRPCError({
@@ -1 +0,0 @@
1
- {"version":3,"file":"node-http-BmySCIg9.mjs","names":[],"sources":["../src/adapters/node-http/incomingMessageToRequest.ts","../src/adapters/node-http/writeResponse.ts","../src/adapters/node-http/nodeHTTPRequestHandler.ts"],"sourcesContent":["import type * as http from 'http';\nimport { IncomingMessage } from 'node:http';\nimport { TRPCError } from '../../@trpc/server';\nimport type { NodeHTTPRequest, NodeHTTPResponse } from './types';\n\nfunction createBody(\n req: NodeHTTPRequest,\n opts: {\n /**\n * Max body size in bytes. If the body is larger than this, the request will be aborted\n */\n maxBodySize: number | null;\n },\n): RequestInit['body'] {\n // Some adapters will pre-parse the body and add it to the request object\n if ('body' in req) {\n if (req.body !== undefined) {\n // If the body is already a string, return it directly\n if (typeof req.body === 'string') {\n return req.body;\n }\n // formData use\n if (req.body instanceof IncomingMessage) {\n return req.body as any;\n }\n // If body exists but isn't a string, stringify it as JSON\n return JSON.stringify(req.body);\n }\n if (req.readableEnded) {\n // The stream was consumed without producing a parsed body — there is\n // nothing left to read\n return undefined;\n }\n // The property was defined without the stream being read — e.g. express\n // 5's body-parser assigns `req.body = undefined` on content types it\n // skips (such as multipart/form-data) — so stream it like an unparsed\n // request\n } else if (req.readableEnded) {\n // Another middleware drained the stream without handing over what it\n // read, so waiting for `data`/`end` would hang forever\n return new ReadableStream({\n start(controller) {\n controller.error(\n new TRPCError({\n code: 'INTERNAL_SERVER_ERROR',\n message:\n 'The request body has already been read by another middleware. Assign the parsed body to `req.body` so tRPC can use it',\n }),\n );\n },\n });\n }\n let size = 0;\n let hasClosed = false;\n\n return new ReadableStream({\n start(controller) {\n const onData = (chunk: Buffer) => {\n size += chunk.length;\n if (!opts.maxBodySize || size <= opts.maxBodySize) {\n controller.enqueue(\n new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength),\n );\n return;\n }\n controller.error(\n new TRPCError({\n code: 'PAYLOAD_TOO_LARGE',\n }),\n );\n hasClosed = true;\n req.off('data', onData);\n req.off('end', onEnd);\n };\n\n const onEnd = () => {\n if (hasClosed) {\n return;\n }\n hasClosed = true;\n req.off('data', onData);\n req.off('end', onEnd);\n controller.close();\n };\n\n req.on('data', onData);\n req.on('end', onEnd);\n },\n cancel() {\n req.destroy();\n },\n });\n}\n/**\n * The full URL of a Node.js request, from its `Host` header and socket.\n * Throws a `BAD_REQUEST` error if it isn't a valid URL.\n */\nexport function createURL(req: NodeHTTPRequest): URL {\n try {\n const protocol =\n // http2\n (req.headers[':scheme'] && req.headers[':scheme'] === 'https') ||\n // http1\n (req.socket && 'encrypted' in req.socket && req.socket.encrypted)\n ? 'https:'\n : 'http:';\n\n const host = req.headers.host ?? req.headers[':authority'] ?? 'localhost';\n\n // oxlint-disable-next-line typescript/no-non-null-assertion\n return new URL(req.url!, `${protocol}//${host}`);\n } catch (cause) {\n throw new TRPCError({\n code: 'BAD_REQUEST',\n message: 'Invalid URL',\n cause,\n });\n }\n}\n\nfunction createHeaders(incoming: http.IncomingHttpHeaders): Headers {\n const headers = new Headers();\n\n for (const key in incoming) {\n const value = incoming[key];\n if (typeof key === 'string' && key.startsWith(':')) {\n // Skip HTTP/2 pseudo-headers\n continue;\n }\n\n if (Array.isArray(value)) {\n for (const item of value) {\n headers.append(key, item);\n }\n } else if (value != null) {\n headers.append(key, value);\n }\n }\n\n return headers;\n}\n\n/**\n * Turns a Node.js `IncomingMessage` into a Fetch API `Request`. The\n * request's signal aborts when the client disconnects.\n */\nexport function incomingMessageToRequest(\n req: NodeHTTPRequest,\n res: NodeHTTPResponse,\n opts: {\n /**\n * Max body size in bytes. If the body is larger than this, the request will be aborted\n */\n maxBodySize: number | null;\n },\n): Request {\n const ac = new AbortController();\n\n const onAbort = () => {\n res.off('close', onClose);\n req.off('aborted', onAbort);\n\n // abort the request\n ac.abort();\n };\n\n const onClose = () => {\n // `close` is also emitted after a response that was sent completely,\n // so only abort if the connection closed before the response was ended\n if (res.writableEnded) {\n req.off('aborted', onAbort);\n return;\n }\n onAbort();\n };\n\n res.once('close', onClose);\n req.once('aborted', onAbort);\n\n // Get host from either regular header or HTTP/2 pseudo-header\n const url = createURL(req);\n\n const init: RequestInit = {\n headers: createHeaders(req.headers),\n method: req.method,\n signal: ac.signal,\n };\n\n if (req.method !== 'GET' && req.method !== 'HEAD') {\n init.body = createBody(req, opts);\n\n // init.duplex = 'half' must be set when body is a ReadableStream, and Node follows the spec.\n // However, this property is not defined in the TypeScript types for RequestInit, so we have\n // to cast it here in order to set it without a type error.\n // See https://fetch.spec.whatwg.org/#dom-requestinit-duplex\n // @ts-expect-error this is fine\n init.duplex = 'half';\n }\n\n const request = new Request(url, init);\n\n return request;\n}\n","// oxlint-disable-next-line no-restricted-imports\nimport { isAbortError } from '../../unstable-core-do-not-import';\nimport type { NodeHTTPResponse } from './types';\n\nasync function writeResponseBodyChunk(\n res: NodeHTTPResponse,\n chunk: Uint8Array,\n) {\n // useful for debugging 🙃\n // console.debug('writing', new TextDecoder().decode(chunk));\n\n if (res.write(chunk) === false) {\n await new Promise<void>((resolve, reject) => {\n const onError = (err: unknown) => {\n reject(err);\n cleanup();\n };\n const onDrain = () => {\n resolve();\n cleanup();\n };\n const cleanup = () => {\n res.off('error', onError);\n res.off('drain', onDrain);\n res.off('close', onDrain);\n };\n res.once('error', onError);\n res.once('drain', onDrain);\n res.once('close', onDrain);\n });\n }\n}\n/**\n * @internal\n */\n\nexport async function writeResponseBody(opts: {\n res: NodeHTTPResponse;\n signal: AbortSignal;\n body: NonNullable<Response['body']>;\n}) {\n const { res } = opts;\n\n try {\n const writableStream = new WritableStream({\n async write(chunk) {\n await writeResponseBodyChunk(res, chunk);\n res.flush?.();\n },\n });\n\n await opts.body.pipeTo(writableStream, {\n signal: opts.signal,\n });\n } catch (err) {\n if (isAbortError(err)) {\n return;\n }\n throw err;\n }\n}\n/**\n * @internal\n */\n\nexport async function writeResponse(opts: {\n request: Request;\n response: Response;\n rawResponse: NodeHTTPResponse;\n}) {\n const { response, rawResponse } = opts;\n\n // Only override status code if it hasn't been explicitly set in a procedure etc\n if (rawResponse.statusCode === 200) {\n rawResponse.statusCode = response.status;\n }\n for (const [key, value] of response.headers) {\n if (key.toLowerCase() === 'set-cookie') continue;\n rawResponse.setHeader(key, value);\n }\n const cookies = response.headers.getSetCookie();\n if (cookies.length > 0) {\n rawResponse.setHeader('set-cookie', cookies);\n }\n try {\n if (response.body) {\n await writeResponseBody({\n res: rawResponse,\n signal: opts.request.signal,\n body: response.body,\n });\n }\n } catch (err) {\n if (!rawResponse.headersSent) {\n rawResponse.statusCode = 500;\n }\n throw err;\n } finally {\n rawResponse.end();\n }\n}\n","/**\n * If you're making an adapter for tRPC and looking at this file for reference, you should import types and functions from `@trpc/server` and `@trpc/server/http`\n *\n * @example\n * ```ts\n * import type { AnyTRPCRouter } from '@trpc/server'\n * import type { HTTPBaseHandlerOptions } from '@trpc/server/http'\n * ```\n */\n\n// @trpc/server\n\nimport {\n getTRPCErrorFromUnknown,\n transformTRPCResponse,\n type AnyRouter,\n} from '../../@trpc/server';\nimport type { ResolveHTTPRequestOptionsContextFn } from '../../@trpc/server/http';\nimport { resolveResponse } from '../../@trpc/server/http';\n// oxlint-disable-next-line no-restricted-imports\nimport { getErrorShape, run } from '../../unstable-core-do-not-import';\nimport { incomingMessageToRequest } from './incomingMessageToRequest';\nimport type {\n NodeHTTPRequest,\n NodeHTTPRequestHandlerOptions,\n NodeHTTPResponse,\n} from './types';\nimport { writeResponse } from './writeResponse';\n\n/**\n * Answers with an error response when handling a request throws.\n * @internal\n */\nexport function internal_exceptionHandler<\n TRouter extends AnyRouter,\n TRequest extends NodeHTTPRequest,\n TResponse extends NodeHTTPResponse,\n>(opts: NodeHTTPRequestHandlerOptions<TRouter, TRequest, TResponse>) {\n return (cause: unknown) => {\n const { res, req } = opts;\n const error = getTRPCErrorFromUnknown(cause);\n\n const shape = getErrorShape({\n config: opts.router._def._config,\n error,\n type: 'unknown',\n path: undefined,\n input: undefined,\n ctx: undefined,\n });\n\n opts.onError?.({\n req,\n error,\n type: 'unknown',\n path: undefined,\n input: undefined,\n ctx: undefined,\n });\n\n const transformed = transformTRPCResponse(opts.router._def._config, {\n error: shape,\n });\n\n res.statusCode = shape.data.httpStatus;\n res.end(JSON.stringify(transformed));\n };\n}\n\n/**\n * Handles a Node.js request for a router. The adapters for Express,\n * Next.js and the standalone server use it. The promise never rejects.\n */\nexport async function nodeHTTPRequestHandler<\n TRouter extends AnyRouter,\n TRequest extends NodeHTTPRequest,\n TResponse extends NodeHTTPResponse,\n>(opts: NodeHTTPRequestHandlerOptions<TRouter, TRequest, TResponse>) {\n return new Promise<void>((resolve) => {\n const handleViaMiddleware =\n opts.middleware ?? ((_req, _res, next) => next());\n\n opts.res.once('finish', () => {\n resolve();\n });\n return handleViaMiddleware(opts.req, opts.res, (err: unknown) => {\n run(async () => {\n const request = incomingMessageToRequest(opts.req, opts.res, {\n maxBodySize: opts.maxBodySize ?? null,\n });\n\n // Build tRPC dependencies\n const createContext: ResolveHTTPRequestOptionsContextFn<\n TRouter\n > = async (innerOpts) => {\n return await opts.createContext?.({\n ...opts,\n ...innerOpts,\n });\n };\n\n const response = await resolveResponse({\n ...opts,\n req: request,\n error: err ? getTRPCErrorFromUnknown(err) : null,\n createContext,\n onError(o) {\n opts?.onError?.({\n ...o,\n req: opts.req,\n });\n },\n });\n\n await writeResponse({\n request,\n response,\n rawResponse: opts.res,\n });\n }).catch(internal_exceptionHandler(opts));\n });\n });\n}\n"],"mappings":";;;;;;AAKA,SAAS,WACP,KACA,MAMqB;CAErB,IAAI,UAAU,KAAK;E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