@trpc/server 11.0.0-rc.477 → 11.0.0-rc.482

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 (25) hide show
  1. package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
  2. package/dist/adapters/fastify/fastifyTRPCPlugin.js +9 -2
  3. package/dist/adapters/fastify/fastifyTRPCPlugin.mjs +10 -3
  4. package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
  5. package/dist/adapters/node-http/nodeHTTPRequestHandler.js +2 -0
  6. package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +2 -0
  7. package/dist/adapters/ws.d.ts +4 -0
  8. package/dist/adapters/ws.d.ts.map +1 -1
  9. package/dist/adapters/ws.js +1 -0
  10. package/dist/adapters/ws.mjs +1 -1
  11. package/dist/bundle-analysis.json +97 -95
  12. package/dist/unstable-core-do-not-import/stream/jsonl.d.ts +1 -1
  13. package/dist/unstable-core-do-not-import/stream/jsonl.d.ts.map +1 -1
  14. package/dist/unstable-core-do-not-import/stream/jsonl.js +17 -12
  15. package/dist/unstable-core-do-not-import/stream/jsonl.mjs +18 -13
  16. package/dist/unstable-core-do-not-import/stream/utils/createReadableStream.d.ts +4 -1
  17. package/dist/unstable-core-do-not-import/stream/utils/createReadableStream.d.ts.map +1 -1
  18. package/dist/unstable-core-do-not-import/stream/utils/createReadableStream.js +6 -1
  19. package/dist/unstable-core-do-not-import/stream/utils/createReadableStream.mjs +6 -2
  20. package/package.json +2 -2
  21. package/src/adapters/fastify/fastifyTRPCPlugin.ts +11 -5
  22. package/src/adapters/node-http/nodeHTTPRequestHandler.ts +4 -0
  23. package/src/adapters/ws.ts +1 -1
  24. package/src/unstable-core-do-not-import/stream/jsonl.ts +15 -9
  25. package/src/unstable-core-do-not-import/stream/utils/createReadableStream.ts +9 -2
@@ -1 +1 @@
1
- {"version":3,"file":"fastifyTRPCPlugin.d.ts","sourceRoot":"","sources":["../../../src/adapters/fastify/fastifyTRPCPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAGnE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAGrE,MAAM,WAAW,wBAAwB,CAAC,OAAO,SAAS,SAAS;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,qBAAqB,CAAC,OAAO,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;CAC3E;AAED,MAAM,MAAM,2BAA2B,GAAG,8BAA8B,CACtE,cAAc,EACd,YAAY,CACb,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,SAAS,EACzD,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,EACvC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,IAAI,QAmC5B"}
1
+ {"version":3,"file":"fastifyTRPCPlugin.d.ts","sourceRoot":"","sources":["../../../src/adapters/fastify/fastifyTRPCPlugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAGnE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAGrE,MAAM,WAAW,wBAAwB,CAAC,OAAO,SAAS,SAAS;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,qBAAqB,CAAC,OAAO,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;CAC3E;AAED,MAAM,MAAM,2BAA2B,GAAG,8BAA8B,CACtE,cAAc,EACd,YAAY,CACb,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,SAAS,EACzD,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,EACvC,IAAI,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,IAAI,QAyC5B"}
@@ -36,12 +36,19 @@ function fastifyTRPCPlugin(fastify, opts, done) {
36
36
  });
37
37
  });
38
38
  if (opts.useWSS) {
39
+ const trpcOptions = opts.trpcOptions;
39
40
  const onConnection = ws.getWSConnectionHandler({
40
- ...opts.trpcOptions
41
+ ...trpcOptions
41
42
  });
42
43
  fastify.get(prefix ?? '/', {
43
44
  websocket: true
44
- }, (socket, req)=>onConnection(socket, req.raw));
45
+ }, async (socket, req)=>{
46
+ await onConnection(socket, req.raw);
47
+ if (trpcOptions?.keepAlive?.enabled) {
48
+ const { pingMs , pongWaitMs } = trpcOptions.keepAlive;
49
+ ws.handleKeepAlive(socket, pingMs, pongWaitMs);
50
+ }
51
+ });
45
52
  }
46
53
  done();
47
54
  }
@@ -1,4 +1,4 @@
1
- import { getWSConnectionHandler } from '../ws.mjs';
1
+ import { getWSConnectionHandler, handleKeepAlive } from '../ws.mjs';
2
2
  import { fastifyRequestHandler } from './fastifyRequestHandler.mjs';
3
3
 
4
4
  /**
@@ -34,12 +34,19 @@ function fastifyTRPCPlugin(fastify, opts, done) {
34
34
  });
35
35
  });
36
36
  if (opts.useWSS) {
37
+ const trpcOptions = opts.trpcOptions;
37
38
  const onConnection = getWSConnectionHandler({
38
- ...opts.trpcOptions
39
+ ...trpcOptions
39
40
  });
40
41
  fastify.get(prefix ?? '/', {
41
42
  websocket: true
42
- }, (socket, req)=>onConnection(socket, req.raw));
43
+ }, async (socket, req)=>{
44
+ await onConnection(socket, req.raw);
45
+ if (trpcOptions?.keepAlive?.enabled) {
46
+ const { pingMs , pongWaitMs } = trpcOptions.keepAlive;
47
+ handleKeepAlive(socket, pingMs, pongWaitMs);
48
+ }
49
+ });
43
50
  }
44
51
  done();
45
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"nodeHTTPRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/node-http/nodeHTTPRequestHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAA2B,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI7E,OAAO,KAAK,EACV,eAAe,EACf,6BAA6B,EAC7B,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAEjB,wBAAsB,sBAAsB,CAC1C,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,EAClC,IAAI,EAAE,6BAA6B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,iBAwElE"}
1
+ {"version":3,"file":"nodeHTTPRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/node-http/nodeHTTPRequestHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,EAA2B,KAAK,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAI7E,OAAO,KAAK,EACV,eAAe,EACf,6BAA6B,EAC7B,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAEjB,wBAAsB,sBAAsB,CAC1C,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,EAClC,IAAI,EAAE,6BAA6B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,iBA4ElE"}
@@ -71,6 +71,8 @@ async function nodeHTTPRequestHandler(opts) {
71
71
  res.once('drain', resolve);
72
72
  });
73
73
  }
74
+ // useful for debugging chunked responses:
75
+ // console.log('wrote', Buffer.from(value).toString());
74
76
  // IMPORTANT - flush the response buffer, otherwise the client will not receive the data until `.end()`
75
77
  res.flush?.();
76
78
  }
@@ -69,6 +69,8 @@ async function nodeHTTPRequestHandler(opts) {
69
69
  res.once('drain', resolve);
70
70
  });
71
71
  }
72
+ // useful for debugging chunked responses:
73
+ // console.log('wrote', Buffer.from(value).toString());
72
74
  // IMPORTANT - flush the response buffer, otherwise the client will not receive the data until `.end()`
73
75
  res.flush?.();
74
76
  }
@@ -38,6 +38,10 @@ export type WSSHandlerOptions<TRouter extends AnyRouter> = WSConnectionHandlerOp
38
38
  };
39
39
  };
40
40
  export declare function getWSConnectionHandler<TRouter extends AnyRouter>(opts: WSConnectionHandlerOptions<TRouter>): (client: ws.WebSocket, req: IncomingMessage) => Promise<void>;
41
+ /**
42
+ * Handle WebSocket keep-alive messages
43
+ */
44
+ export declare function handleKeepAlive(client: ws.WebSocket, pingMs?: number, pongWaitMs?: number): void;
41
45
  export declare function applyWSSHandler<TRouter extends AnyRouter>(opts: WSSHandlerOptions<TRouter>): {
42
46
  broadcastReconnectNotification: () => void;
43
47
  };
@@ -1 +1 @@
1
- {"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../src/adapters/ws.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,EACV,SAAS,EACT,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AASzB,OAAO,EAAS,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AActE,OAAO,EAKL,KAAK,YAAY,EAClB,MAAM,gCAAgC,CAAC;AACxC,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAQlE;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,8BAA8B,CACpE,eAAe,EACf,EA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O,QAuBlB;AAED,wBAAgB,eAAe,CAAC,OAAO,SAAS,SAAS,EACvD,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC;;EA+BjC"}
@@ -406,3 +406,4 @@ function applyWSSHandler(opts) {
406
406
 
407
407
  exports.applyWSSHandler = applyWSSHandler;
408
408
  exports.getWSConnectionHandler = getWSConnectionHandler;
409
+ exports.handleKeepAlive = handleKeepAlive;
@@ -402,4 +402,4 @@ function applyWSSHandler(opts) {
402
402
  };
403
403
  }
404
404
 
405
- export { applyWSSHandler, getWSConnectionHandler };
405
+ export { applyWSSHandler, getWSConnectionHandler, handleKeepAlive };
@@ -1,7 +1,7 @@
1
1
  {
2
- "bundleSize": 134783,
3
- "bundleOrigSize": 183711,
4
- "bundleReduction": 26.63,
2
+ "bundleSize": 135515,
3
+ "bundleOrigSize": 184418,
4
+ "bundleReduction": 26.52,
5
5
  "modules": [
6
6
  {
7
7
  "id": "/src/unstable-core-do-not-import/http/resolveResponse.ts",
@@ -14,13 +14,13 @@
14
14
  "dependents": [
15
15
  "/src/unstable-core-do-not-import.ts"
16
16
  ],
17
- "percent": 13.18,
17
+ "percent": 13.11,
18
18
  "reduction": 0
19
19
  },
20
20
  {
21
21
  "id": "/src/unstable-core-do-not-import/stream/jsonl.ts",
22
- "size": 17400,
23
- "origSize": 18243,
22
+ "size": 17567,
23
+ "origSize": 18359,
24
24
  "renderedExports": [
25
25
  "isPromise",
26
26
  "jsonlStreamProducer",
@@ -31,22 +31,23 @@
31
31
  "/src/unstable-core-do-not-import.ts",
32
32
  "/src/unstable-core-do-not-import/http/resolveResponse.ts"
33
33
  ],
34
- "percent": 12.91,
35
- "reduction": 4.62
34
+ "percent": 12.96,
35
+ "reduction": 4.31
36
36
  },
37
37
  {
38
38
  "id": "/src/adapters/ws.ts",
39
39
  "size": 15730,
40
- "origSize": 14665,
40
+ "origSize": 14672,
41
41
  "renderedExports": [
42
42
  "getWSConnectionHandler",
43
+ "handleKeepAlive",
43
44
  "applyWSSHandler"
44
45
  ],
45
46
  "removedExports": [],
46
47
  "dependents": [
47
48
  "/src/adapters/fastify/fastifyTRPCPlugin.ts"
48
49
  ],
49
- "percent": 11.67,
50
+ "percent": 11.61,
50
51
  "reduction": 0
51
52
  },
52
53
  {
@@ -61,7 +62,7 @@
61
62
  "/src/unstable-core-do-not-import.ts",
62
63
  "/src/unstable-core-do-not-import/http/resolveResponse.ts"
63
64
  ],
64
- "percent": 5.7,
65
+ "percent": 5.67,
65
66
  "reduction": 0
66
67
  },
67
68
  {
@@ -79,7 +80,7 @@
79
80
  "/src/unstable-core-do-not-import.ts",
80
81
  "/src/unstable-core-do-not-import/initTRPC.ts"
81
82
  ],
82
- "percent": 4.73,
83
+ "percent": 4.71,
83
84
  "reduction": 39.77
84
85
  },
85
86
  {
@@ -94,7 +95,7 @@
94
95
  "/src/unstable-core-do-not-import.ts",
95
96
  "/src/unstable-core-do-not-import/initTRPC.ts"
96
97
  ],
97
- "percent": 4.69,
98
+ "percent": 4.67,
98
99
  "reduction": 60.09
99
100
  },
100
101
  {
@@ -111,7 +112,7 @@
111
112
  "/src/unstable-core-do-not-import.ts",
112
113
  "/src/unstable-core-do-not-import/http/resolveResponse.ts"
113
114
  ],
114
- "percent": 4.38,
115
+ "percent": 4.36,
115
116
  "reduction": 15.22
116
117
  },
117
118
  {
@@ -125,7 +126,7 @@
125
126
  "dependents": [
126
127
  "/src/adapters/aws-lambda/index.ts"
127
128
  ],
128
- "percent": 4.02,
129
+ "percent": 4,
129
130
  "reduction": 11.38
130
131
  },
131
132
  {
@@ -145,7 +146,7 @@
145
146
  "/src/unstable-core-do-not-import/http/resolveResponse.ts",
146
147
  "/src/observable/operators.ts"
147
148
  ],
148
- "percent": 3.05,
149
+ "percent": 3.04,
149
150
  "reduction": 0
150
151
  },
151
152
  {
@@ -159,9 +160,23 @@
159
160
  "dependents": [
160
161
  "/src/adapters/next-app-dir.ts"
161
162
  ],
162
- "percent": 2.33,
163
+ "percent": 2.31,
163
164
  "reduction": 23.5
164
165
  },
166
+ {
167
+ "id": "/src/adapters/node-http/nodeHTTPRequestHandler.ts",
168
+ "size": 2863,
169
+ "origSize": 3048,
170
+ "renderedExports": [
171
+ "nodeHTTPRequestHandler"
172
+ ],
173
+ "removedExports": [],
174
+ "dependents": [
175
+ "/src/adapters/node-http/index.ts"
176
+ ],
177
+ "percent": 2.11,
178
+ "reduction": 6.07
179
+ },
165
180
  {
166
181
  "id": "/src/observable/operators.ts",
167
182
  "size": 2756,
@@ -175,7 +190,7 @@
175
190
  "dependents": [
176
191
  "/src/observable/index.ts"
177
192
  ],
178
- "percent": 2.04,
193
+ "percent": 2.03,
179
194
  "reduction": 0
180
195
  },
181
196
  {
@@ -191,27 +206,13 @@
191
206
  "removedExports": [],
192
207
  "dependents": [
193
208
  "/src/unstable-core-do-not-import.ts",
209
+ "/src/unstable-core-do-not-import/http/resolveResponse.ts",
194
210
  "/src/unstable-core-do-not-import/initTRPC.ts",
195
- "/src/unstable-core-do-not-import/router.ts",
196
- "/src/unstable-core-do-not-import/http/resolveResponse.ts"
211
+ "/src/unstable-core-do-not-import/router.ts"
197
212
  ],
198
- "percent": 2.04,
213
+ "percent": 2.02,
199
214
  "reduction": 45.94
200
215
  },
201
- {
202
- "id": "/src/adapters/node-http/nodeHTTPRequestHandler.ts",
203
- "size": 2732,
204
- "origSize": 2931,
205
- "renderedExports": [
206
- "nodeHTTPRequestHandler"
207
- ],
208
- "removedExports": [],
209
- "dependents": [
210
- "/src/adapters/node-http/index.ts"
211
- ],
212
- "percent": 2.03,
213
- "reduction": 6.79
214
- },
215
216
  {
216
217
  "id": "/src/unstable-core-do-not-import/initTRPC.ts",
217
218
  "size": 2704,
@@ -223,7 +224,7 @@
223
224
  "dependents": [
224
225
  "/src/unstable-core-do-not-import.ts"
225
226
  ],
226
- "percent": 2.01,
227
+ "percent": 2,
227
228
  "reduction": 40.91
228
229
  },
229
230
  {
@@ -243,7 +244,7 @@
243
244
  "/src/unstable-core-do-not-import/initTRPC.ts",
244
245
  "/src/unstable-core-do-not-import/procedureBuilder.ts"
245
246
  ],
246
- "percent": 1.95,
247
+ "percent": 1.94,
247
248
  "reduction": 55.5
248
249
  },
249
250
  {
@@ -259,7 +260,7 @@
259
260
  "/src/unstable-core-do-not-import.ts",
260
261
  "/src/unstable-core-do-not-import/router.ts"
261
262
  ],
262
- "percent": 1.73,
263
+ "percent": 1.72,
263
264
  "reduction": 0
264
265
  },
265
266
  {
@@ -273,7 +274,7 @@
273
274
  "dependents": [
274
275
  "/src/adapters/fetch/index.ts"
275
276
  ],
276
- "percent": 1.67,
277
+ "percent": 1.66,
277
278
  "reduction": 2.17
278
279
  },
279
280
  {
@@ -288,7 +289,7 @@
288
289
  "/src/adapters/node-http/index.ts",
289
290
  "/src/adapters/node-http/nodeHTTPRequestHandler.ts"
290
291
  ],
291
- "percent": 1.63,
292
+ "percent": 1.62,
292
293
  "reduction": 13.79
293
294
  },
294
295
  {
@@ -302,9 +303,23 @@
302
303
  "dependents": [
303
304
  "/src/adapters/next-app-dir/nextAppDirCaller.ts"
304
305
  ],
305
- "percent": 1.52,
306
+ "percent": 1.51,
306
307
  "reduction": 5.79
307
308
  },
309
+ {
310
+ "id": "/src/adapters/fastify/fastifyTRPCPlugin.ts",
311
+ "size": 1779,
312
+ "origSize": 2537,
313
+ "renderedExports": [
314
+ "fastifyTRPCPlugin"
315
+ ],
316
+ "removedExports": [],
317
+ "dependents": [
318
+ "/src/adapters/fastify/index.ts"
319
+ ],
320
+ "percent": 1.31,
321
+ "reduction": 29.88
322
+ },
308
323
  {
309
324
  "id": "/src/unstable-core-do-not-import/error/TRPCError.ts",
310
325
  "size": 1733,
@@ -317,16 +332,16 @@
317
332
  "removedExports": [],
318
333
  "dependents": [
319
334
  "/src/unstable-core-do-not-import.ts",
320
- "/src/unstable-core-do-not-import/middleware.ts",
321
- "/src/unstable-core-do-not-import/router.ts",
322
335
  "/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
323
336
  "/src/unstable-core-do-not-import/http/resolveResponse.ts",
337
+ "/src/unstable-core-do-not-import/middleware.ts",
338
+ "/src/unstable-core-do-not-import/router.ts",
324
339
  "/src/unstable-core-do-not-import/http/contentType.ts",
325
340
  "/src/unstable-core-do-not-import/procedureBuilder.ts",
326
341
  "/src/unstable-core-do-not-import/stream/jsonl.ts",
327
342
  "/src/unstable-core-do-not-import/stream/sse.ts"
328
343
  ],
329
- "percent": 1.29,
344
+ "percent": 1.28,
330
345
  "reduction": 19.47
331
346
  },
332
347
  {
@@ -338,7 +353,7 @@
338
353
  ],
339
354
  "removedExports": [],
340
355
  "dependents": [],
341
- "percent": 1.26,
356
+ "percent": 1.25,
342
357
  "reduction": 19.29
343
358
  },
344
359
  {
@@ -351,7 +366,7 @@
351
366
  ],
352
367
  "removedExports": [],
353
368
  "dependents": [],
354
- "percent": 1.2,
369
+ "percent": 1.19,
355
370
  "reduction": 27.47
356
371
  },
357
372
  {
@@ -366,20 +381,6 @@
366
381
  "percent": 1.14,
367
382
  "reduction": 26.94
368
383
  },
369
- {
370
- "id": "/src/adapters/fastify/fastifyTRPCPlugin.ts",
371
- "size": 1500,
372
- "origSize": 2297,
373
- "renderedExports": [
374
- "fastifyTRPCPlugin"
375
- ],
376
- "removedExports": [],
377
- "dependents": [
378
- "/src/adapters/fastify/index.ts"
379
- ],
380
- "percent": 1.11,
381
- "reduction": 34.7
382
- },
383
384
  {
384
385
  "id": "/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
385
386
  "size": 1365,
@@ -391,8 +392,8 @@
391
392
  "removedExports": [],
392
393
  "dependents": [
393
394
  "/src/unstable-core-do-not-import.ts",
394
- "/src/unstable-core-do-not-import/error/getErrorShape.ts",
395
- "/src/unstable-core-do-not-import/http/resolveResponse.ts"
395
+ "/src/unstable-core-do-not-import/http/resolveResponse.ts",
396
+ "/src/unstable-core-do-not-import/error/getErrorShape.ts"
396
397
  ],
397
398
  "percent": 1.01,
398
399
  "reduction": 17.52
@@ -413,20 +414,20 @@
413
414
  "removedExports": [],
414
415
  "dependents": [
415
416
  "/src/unstable-core-do-not-import.ts",
417
+ "/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
418
+ "/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
419
+ "/src/unstable-core-do-not-import/http/resolveResponse.ts",
416
420
  "/src/unstable-core-do-not-import/error/TRPCError.ts",
417
421
  "/src/unstable-core-do-not-import/transformer.ts",
418
422
  "/src/unstable-core-do-not-import/middleware.ts",
419
423
  "/src/unstable-core-do-not-import/router.ts",
420
- "/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
421
- "/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
422
- "/src/unstable-core-do-not-import/http/resolveResponse.ts",
423
424
  "/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
424
425
  "/src/unstable-core-do-not-import/http/contentType.ts",
425
426
  "/src/unstable-core-do-not-import/procedureBuilder.ts",
426
427
  "/src/unstable-core-do-not-import/stream/jsonl.ts",
427
428
  "/src/unstable-core-do-not-import/stream/sse.ts"
428
429
  ],
429
- "percent": 0.89,
430
+ "percent": 0.88,
430
431
  "reduction": 28.12
431
432
  },
432
433
  {
@@ -457,7 +458,7 @@
457
458
  "/src/unstable-core-do-not-import.ts",
458
459
  "/src/unstable-core-do-not-import/http/contentType.ts"
459
460
  ],
460
- "percent": 0.82,
461
+ "percent": 0.81,
461
462
  "reduction": 15.08
462
463
  },
463
464
  {
@@ -471,7 +472,7 @@
471
472
  "dependents": [
472
473
  "/src/unstable-core-do-not-import.ts"
473
474
  ],
474
- "percent": 0.79,
475
+ "percent": 0.78,
475
476
  "reduction": 0
476
477
  },
477
478
  {
@@ -486,7 +487,7 @@
486
487
  "/src/unstable-core-do-not-import.ts",
487
488
  "/src/unstable-core-do-not-import/procedureBuilder.ts"
488
489
  ],
489
- "percent": 0.77,
490
+ "percent": 0.76,
490
491
  "reduction": 58.57
491
492
  },
492
493
  {
@@ -553,6 +554,22 @@
553
554
  "percent": 0.56,
554
555
  "reduction": 66.9
555
556
  },
557
+ {
558
+ "id": "/src/unstable-core-do-not-import/stream/utils/createReadableStream.ts",
559
+ "size": 730,
560
+ "origSize": 921,
561
+ "renderedExports": [
562
+ "createReadableStream",
563
+ "isCancelledStreamResult"
564
+ ],
565
+ "removedExports": [],
566
+ "dependents": [
567
+ "/src/unstable-core-do-not-import/stream/jsonl.ts",
568
+ "/src/unstable-core-do-not-import/stream/sse.ts"
569
+ ],
570
+ "percent": 0.54,
571
+ "reduction": 20.74
572
+ },
556
573
  {
557
574
  "id": "/src/unstable-core-do-not-import/http/batchStreamFormatter.ts",
558
575
  "size": 667,
@@ -582,21 +599,6 @@
582
599
  "percent": 0.46,
583
600
  "reduction": 43.49
584
601
  },
585
- {
586
- "id": "/src/unstable-core-do-not-import/stream/utils/createReadableStream.ts",
587
- "size": 575,
588
- "origSize": 694,
589
- "renderedExports": [
590
- "createReadableStream"
591
- ],
592
- "removedExports": [],
593
- "dependents": [
594
- "/src/unstable-core-do-not-import/stream/jsonl.ts",
595
- "/src/unstable-core-do-not-import/stream/sse.ts"
596
- ],
597
- "percent": 0.43,
598
- "reduction": 17.15
599
- },
600
602
  {
601
603
  "id": "/src/adapters/standalone.ts",
602
604
  "size": 520,
@@ -607,7 +609,7 @@
607
609
  ],
608
610
  "removedExports": [],
609
611
  "dependents": [],
610
- "percent": 0.39,
612
+ "percent": 0.38,
611
613
  "reduction": 67.09
612
614
  },
613
615
  {
@@ -648,7 +650,7 @@
648
650
  "dependents": [
649
651
  "/src/unstable-core-do-not-import.ts"
650
652
  ],
651
- "percent": 0.21,
653
+ "percent": 0.2,
652
654
  "reduction": 68.45
653
655
  },
654
656
  {
@@ -725,24 +727,24 @@
725
727
  "reduction": 93.8
726
728
  },
727
729
  {
728
- "id": "/src/index.ts",
730
+ "id": "/src/http.ts",
729
731
  "size": 0,
730
- "origSize": 32,
732
+ "origSize": 37,
731
733
  "renderedExports": [],
732
734
  "removedExports": [],
733
- "dependents": [],
735
+ "dependents": [
736
+ "/src/adapters/ws.ts"
737
+ ],
734
738
  "percent": 0,
735
739
  "reduction": 100
736
740
  },
737
741
  {
738
- "id": "/src/http.ts",
742
+ "id": "/src/index.ts",
739
743
  "size": 0,
740
- "origSize": 37,
744
+ "origSize": 32,
741
745
  "renderedExports": [],
742
746
  "removedExports": [],
743
- "dependents": [
744
- "/src/adapters/ws.ts"
745
- ],
747
+ "dependents": [],
746
748
  "percent": 0,
747
749
  "reduction": 100
748
750
  },
@@ -829,8 +831,8 @@
829
831
  "removedExports": [],
830
832
  "dependents": [
831
833
  "/src/adapters/express.ts",
832
- "/src/adapters/next.ts",
833
834
  "/src/adapters/standalone.ts",
835
+ "/src/adapters/next.ts",
834
836
  "/src/adapters/fastify/fastifyRequestHandler.ts"
835
837
  ],
836
838
  "percent": 0,
@@ -35,7 +35,7 @@ type ChunkDefinition = [
35
35
  type DehydratedValue = [
36
36
  [
37
37
  unknown
38
- ],
38
+ ] | [],
39
39
  ...ChunkDefinition[]
40
40
  ];
41
41
  type PromiseChunk = [
@@ -1 +1 @@
1
- {"version":3,"file":"jsonl.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/stream/jsonl.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,SAAS,EAAE,MAAM,2BAA2B,CAAC,UAAU,CAAC,CAAC;CAC1D,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,EAAE,CACA,SAAS,EAAE,MAAM,GAAG,MAAM,EAC1B,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,GACjC,yBAAyB,CAAC;CAC9B,CAAC;AAGF,QAAA,MAAM,wBAAwB,IAAI,CAAC;AACnC,KAAK,wBAAwB,GAAG,OAAO,wBAAwB,CAAC;AAChE,QAAA,MAAM,+BAA+B,IAAI,CAAC;AAC1C,KAAK,+BAA+B,GAAG,OAAO,+BAA+B,CAAC;AAE9E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C9C,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE;IACnC,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,SAAS,CAAC;CACjB,KAAK,IAAI,CAAC;AACX,MAAM,WAAW,eAAe;IAC9B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,EAAE,CAAC;IAC1C,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,SAAS,CAAA;KAAE,KAAK,OAAO,CAAC;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AA8LD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,eAAe,8BA2BxD;AAED,cAAM,sBAAuB,SAAQ,KAAK;gBAC5B,KAAK,CAAC,EAAE,OAAO;CAK5B;AAMD,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,KAAK,IAAI,CAAC;AAgFjE;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,IAAI,EAAE;IACrD,IAAI,EAAE,yBAAyB,GAAG,sBAAsB,CAAC;IACzD,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,KAAK,KAAK,CAAC;IAClD,eAAe,EAAE,eAAe,GAAG,IAAI,CAAC;CACzC;;;kBAmBa,OAAO;;IA6MpB"}
@@ -48,7 +48,7 @@ function createBatchStreamProducer(opts) {
48
48
  promise,
49
49
  stream.cancelledPromise
50
50
  ]).then((it)=>{
51
- if (it === null) {
51
+ if (createReadableStream.isCancelledStreamResult(it)) {
52
52
  return;
53
53
  }
54
54
  stream.controller.enqueue([
@@ -108,7 +108,7 @@ function createBatchStreamProducer(opts) {
108
108
  ]);
109
109
  return;
110
110
  }
111
- if (next === 'cancelled') {
111
+ if (createReadableStream.isCancelledStreamResult(next)) {
112
112
  await iterator.return?.();
113
113
  break;
114
114
  }
@@ -147,7 +147,7 @@ function createBatchStreamProducer(opts) {
147
147
  }
148
148
  return null;
149
149
  }
150
- function dehydrateChunk(value, path) {
150
+ function dehydrateAsync(value, path) {
151
151
  if (isPromise(value)) {
152
152
  return [
153
153
  CHUNK_VALUE_TYPE_PROMISE,
@@ -166,7 +166,19 @@ function createBatchStreamProducer(opts) {
166
166
  return null;
167
167
  }
168
168
  function dehydrate(value, path) {
169
- const reg = dehydrateChunk(value, path);
169
+ if (value === undefined) {
170
+ return [
171
+ []
172
+ ];
173
+ }
174
+ if (!utils.isObject(value)) {
175
+ return [
176
+ [
177
+ value
178
+ ]
179
+ ];
180
+ }
181
+ const reg = dehydrateAsync(value, path);
170
182
  if (reg) {
171
183
  return [
172
184
  [
@@ -178,17 +190,10 @@ function createBatchStreamProducer(opts) {
178
190
  ]
179
191
  ];
180
192
  }
181
- if (!utils.isObject(value)) {
182
- return [
183
- [
184
- value
185
- ]
186
- ];
187
- }
188
193
  const newObj = {};
189
194
  const asyncValues = [];
190
195
  for (const [key, item] of Object.entries(value)){
191
- const transformed = dehydrateChunk(item, [
196
+ const transformed = dehydrateAsync(item, [
192
197
  ...path,
193
198
  key
194
199
  ]);
@@ -1,7 +1,7 @@
1
1
  import { getTRPCErrorFromUnknown } from '../error/TRPCError.mjs';
2
2
  import { isObject, isFunction, isAsyncIterable, run } from '../utils.mjs';
3
3
  import { createDeferred } from './utils/createDeferred.mjs';
4
- import { createReadableStream } from './utils/createReadableStream.mjs';
4
+ import { createReadableStream, isCancelledStreamResult } from './utils/createReadableStream.mjs';
5
5
 
6
6
  // ---------- types
7
7
  const CHUNK_VALUE_TYPE_PROMISE = 0;
@@ -46,7 +46,7 @@ function createBatchStreamProducer(opts) {
46
46
  promise,
47
47
  stream.cancelledPromise
48
48
  ]).then((it)=>{
49
- if (it === null) {
49
+ if (isCancelledStreamResult(it)) {
50
50
  return;
51
51
  }
52
52
  stream.controller.enqueue([
@@ -106,7 +106,7 @@ function createBatchStreamProducer(opts) {
106
106
  ]);
107
107
  return;
108
108
  }
109
- if (next === 'cancelled') {
109
+ if (isCancelledStreamResult(next)) {
110
110
  await iterator.return?.();
111
111
  break;
112
112
  }
@@ -145,7 +145,7 @@ function createBatchStreamProducer(opts) {
145
145
  }
146
146
  return null;
147
147
  }
148
- function dehydrateChunk(value, path) {
148
+ function dehydrateAsync(value, path) {
149
149
  if (isPromise(value)) {
150
150
  return [
151
151
  CHUNK_VALUE_TYPE_PROMISE,
@@ -164,7 +164,19 @@ function createBatchStreamProducer(opts) {
164
164
  return null;
165
165
  }
166
166
  function dehydrate(value, path) {
167
- const reg = dehydrateChunk(value, path);
167
+ if (value === undefined) {
168
+ return [
169
+ []
170
+ ];
171
+ }
172
+ if (!isObject(value)) {
173
+ return [
174
+ [
175
+ value
176
+ ]
177
+ ];
178
+ }
179
+ const reg = dehydrateAsync(value, path);
168
180
  if (reg) {
169
181
  return [
170
182
  [
@@ -176,17 +188,10 @@ function createBatchStreamProducer(opts) {
176
188
  ]
177
189
  ];
178
190
  }
179
- if (!isObject(value)) {
180
- return [
181
- [
182
- value
183
- ]
184
- ];
185
- }
186
191
  const newObj = {};
187
192
  const asyncValues = [];
188
193
  for (const [key, item] of Object.entries(value)){
189
- const transformed = dehydrateChunk(item, [
194
+ const transformed = dehydrateAsync(item, [
190
195
  ...path,
191
196
  key
192
197
  ]);
@@ -1,10 +1,13 @@
1
+ declare const cancelledStreamSymbol: unique symbol;
1
2
  /**
2
3
  * One-off readable stream
3
4
  */
4
5
  export declare function createReadableStream<TValue = unknown>(): {
5
6
  readonly readable: ReadableStream<TValue>;
6
7
  readonly controller: ReadableStreamDefaultController<TValue>;
7
- readonly cancelledPromise: Promise<"cancelled">;
8
+ readonly cancelledPromise: Promise<typeof cancelledStreamSymbol>;
8
9
  readonly cancelled: () => boolean;
9
10
  };
11
+ export declare function isCancelledStreamResult(v: unknown): v is typeof cancelledStreamSymbol;
12
+ export {};
10
13
  //# sourceMappingURL=createReadableStream.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createReadableStream.d.ts","sourceRoot":"","sources":["../../../../src/unstable-core-do-not-import/stream/utils/createReadableStream.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,GAAG,OAAO;;;;;EAwBpD"}
1
+ {"version":3,"file":"createReadableStream.d.ts","sourceRoot":"","sources":["../../../../src/unstable-core-do-not-import/stream/utils/createReadableStream.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,qBAAqB,eAAoC,CAAC;AAChE;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,GAAG,OAAO;;;;;EAwBpD;AACD,wBAAgB,uBAAuB,CACrC,CAAC,EAAE,OAAO,GACT,CAAC,IAAI,OAAO,qBAAqB,CAEnC"}
@@ -3,6 +3,7 @@
3
3
  var createDeferred = require('./createDeferred.js');
4
4
 
5
5
  // ---------- utils
6
+ const cancelledStreamSymbol = Symbol('cancelledReadableStream');
6
7
  /**
7
8
  * One-off readable stream
8
9
  */ function createReadableStream() {
@@ -14,7 +15,7 @@ var createDeferred = require('./createDeferred.js');
14
15
  controller = c;
15
16
  },
16
17
  cancel () {
17
- deferred.resolve('cancelled');
18
+ deferred.resolve(cancelledStreamSymbol);
18
19
  cancelled = true;
19
20
  }
20
21
  });
@@ -27,5 +28,9 @@ var createDeferred = require('./createDeferred.js');
27
28
  }
28
29
  };
29
30
  }
31
+ function isCancelledStreamResult(v) {
32
+ return v === cancelledStreamSymbol;
33
+ }
30
34
 
31
35
  exports.createReadableStream = createReadableStream;
36
+ exports.isCancelledStreamResult = isCancelledStreamResult;
@@ -1,6 +1,7 @@
1
1
  import { createDeferred } from './createDeferred.mjs';
2
2
 
3
3
  // ---------- utils
4
+ const cancelledStreamSymbol = Symbol('cancelledReadableStream');
4
5
  /**
5
6
  * One-off readable stream
6
7
  */ function createReadableStream() {
@@ -12,7 +13,7 @@ import { createDeferred } from './createDeferred.mjs';
12
13
  controller = c;
13
14
  },
14
15
  cancel () {
15
- deferred.resolve('cancelled');
16
+ deferred.resolve(cancelledStreamSymbol);
16
17
  cancelled = true;
17
18
  }
18
19
  });
@@ -25,5 +26,8 @@ import { createDeferred } from './createDeferred.mjs';
25
26
  }
26
27
  };
27
28
  }
29
+ function isCancelledStreamResult(v) {
30
+ return v === cancelledStreamSymbol;
31
+ }
28
32
 
29
- export { createReadableStream };
33
+ export { createReadableStream, isCancelledStreamResult };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/server",
3
- "version": "11.0.0-rc.477+a467f8314",
3
+ "version": "11.0.0-rc.482+930e652bf",
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": "a467f831416d19c0bf96139fd4ca576fcf80de2a"
152
+ "gitHead": "930e652bf9edf2ddbd24b3f75d70e887ad31f10e"
153
153
  }
@@ -14,7 +14,7 @@ import type { AnyRouter } from '../../@trpc/server';
14
14
  // @trpc/server/http
15
15
  import type { NodeHTTPCreateContextFnOptions } from '../node-http';
16
16
  // @trpc/server/ws
17
- import { getWSConnectionHandler, type WSSHandlerOptions } from '../ws';
17
+ import { getWSConnectionHandler, handleKeepAlive, type WSSHandlerOptions } from '../ws';
18
18
  import type { FastifyHandlerOptions } from './fastifyRequestHandler';
19
19
  import { fastifyRequestHandler } from './fastifyRequestHandler';
20
20
 
@@ -57,13 +57,19 @@ export function fastifyTRPCPlugin<TRouter extends AnyRouter>(
57
57
  });
58
58
 
59
59
  if (opts.useWSS) {
60
+ const trpcOptions = opts.trpcOptions as unknown as WSSHandlerOptions<TRouter>;
61
+
60
62
  const onConnection = getWSConnectionHandler<TRouter>({
61
- ...(opts.trpcOptions as unknown as WSSHandlerOptions<TRouter>),
63
+ ...trpcOptions,
62
64
  });
63
65
 
64
- fastify.get(prefix ?? '/', { websocket: true }, (socket, req) =>
65
- onConnection(socket, req.raw),
66
- );
66
+ fastify.get(prefix ?? '/', { websocket: true }, async (socket, req) => {
67
+ await onConnection(socket, req.raw);
68
+ if (trpcOptions?.keepAlive?.enabled) {
69
+ const { pingMs, pongWaitMs } = trpcOptions.keepAlive;
70
+ handleKeepAlive(socket, pingMs, pongWaitMs);
71
+ }
72
+ });
67
73
  }
68
74
 
69
75
  done();
@@ -89,6 +89,10 @@ export async function nodeHTTPRequestHandler<
89
89
  res.once('drain', resolve);
90
90
  });
91
91
  }
92
+
93
+ // useful for debugging chunked responses:
94
+ // console.log('wrote', Buffer.from(value).toString());
95
+
92
96
  // IMPORTANT - flush the response buffer, otherwise the client will not receive the data until `.end()`
93
97
  res.flush?.();
94
98
  }
@@ -461,7 +461,7 @@ export function getWSConnectionHandler<TRouter extends AnyRouter>(
461
461
  /**
462
462
  * Handle WebSocket keep-alive messages
463
463
  */
464
- function handleKeepAlive(
464
+ export function handleKeepAlive(
465
465
  client: ws.WebSocket,
466
466
  pingMs = 30000,
467
467
  pongWaitMs = 5000,
@@ -2,7 +2,10 @@ import { getTRPCErrorFromUnknown } from '../error/TRPCError';
2
2
  import { isAsyncIterable, isFunction, isObject, run } from '../utils';
3
3
  import type { Deferred } from './utils/createDeferred';
4
4
  import { createDeferred } from './utils/createDeferred';
5
- import { createReadableStream } from './utils/createReadableStream';
5
+ import {
6
+ createReadableStream,
7
+ isCancelledStreamResult,
8
+ } from './utils/createReadableStream';
6
9
 
7
10
  /**
8
11
  * A subset of the standard ReadableStream properties needed by tRPC internally.
@@ -56,7 +59,7 @@ type ChunkDefinition = [
56
59
  ];
57
60
  type DehydratedValue = [
58
61
  // data
59
- [unknown],
62
+ [unknown] | [],
60
63
  // chunk descriptions
61
64
  ...ChunkDefinition[],
62
65
  ];
@@ -147,7 +150,7 @@ function createBatchStreamProducer(opts: ProducerOptions) {
147
150
 
148
151
  Promise.race([promise, stream.cancelledPromise])
149
152
  .then((it) => {
150
- if (it === null) {
153
+ if (isCancelledStreamResult(it)) {
151
154
  return;
152
155
  }
153
156
  stream.controller.enqueue([
@@ -203,7 +206,7 @@ function createBatchStreamProducer(opts: ProducerOptions) {
203
206
  ]);
204
207
  return;
205
208
  }
206
- if (next === 'cancelled') {
209
+ if (isCancelledStreamResult(next)) {
207
210
  await iterator.return?.();
208
211
  break;
209
212
  }
@@ -246,7 +249,7 @@ function createBatchStreamProducer(opts: ProducerOptions) {
246
249
  }
247
250
  return null;
248
251
  }
249
- function dehydrateChunk(
252
+ function dehydrateAsync(
250
253
  value: unknown,
251
254
  path: (string | number)[],
252
255
  ): null | [type: ChunkValueType, chunkId: ChunkIndex] {
@@ -268,17 +271,20 @@ function createBatchStreamProducer(opts: ProducerOptions) {
268
271
  value: unknown,
269
272
  path: (string | number)[],
270
273
  ): DehydratedValue {
271
- const reg = dehydrateChunk(value, path);
272
- if (reg) {
273
- return [[placeholder], [null, ...reg]];
274
+ if (value === undefined) {
275
+ return [[]];
274
276
  }
275
277
  if (!isObject(value)) {
276
278
  return [[value]];
277
279
  }
280
+ const reg = dehydrateAsync(value, path);
281
+ if (reg) {
282
+ return [[placeholder], [null, ...reg]];
283
+ }
278
284
  const newObj = {} as Record<string, unknown>;
279
285
  const asyncValues: ChunkDefinition[] = [];
280
286
  for (const [key, item] of Object.entries(value)) {
281
- const transformed = dehydrateChunk(item, [...path, key]);
287
+ const transformed = dehydrateAsync(item, [...path, key]);
282
288
  if (!transformed) {
283
289
  newObj[key] = item;
284
290
  continue;
@@ -1,6 +1,8 @@
1
1
  import { createDeferred } from './createDeferred';
2
2
 
3
3
  // ---------- utils
4
+
5
+ const cancelledStreamSymbol = Symbol('cancelledReadableStream');
4
6
  /**
5
7
  * One-off readable stream
6
8
  */
@@ -8,14 +10,14 @@ export function createReadableStream<TValue = unknown>() {
8
10
  let controller: ReadableStreamDefaultController<TValue> =
9
11
  null as unknown as ReadableStreamDefaultController<TValue>;
10
12
 
11
- const deferred = createDeferred<'cancelled'>();
13
+ const deferred = createDeferred<typeof cancelledStreamSymbol>();
12
14
  let cancelled = false;
13
15
  const readable = new ReadableStream<TValue>({
14
16
  start(c) {
15
17
  controller = c;
16
18
  },
17
19
  cancel() {
18
- deferred.resolve('cancelled');
20
+ deferred.resolve(cancelledStreamSymbol);
19
21
  cancelled = true;
20
22
  },
21
23
  });
@@ -29,3 +31,8 @@ export function createReadableStream<TValue = unknown>() {
29
31
  },
30
32
  } as const;
31
33
  }
34
+ export function isCancelledStreamResult(
35
+ v: unknown,
36
+ ): v is typeof cancelledStreamSymbol {
37
+ return v === cancelledStreamSymbol;
38
+ }