@trpc/server 11.0.0-rc.748 → 11.0.0-rc.750

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/node-http/writeResponse.js +2 -2
  2. package/dist/adapters/node-http/writeResponse.mjs +1 -1
  3. package/dist/bundle-analysis.json +52 -50
  4. package/dist/unstable-core-do-not-import/http/{isAbortError.d.ts → abortError.d.ts} +2 -1
  5. package/dist/unstable-core-do-not-import/http/abortError.d.ts.map +1 -0
  6. package/dist/unstable-core-do-not-import/http/{isAbortError.js → abortError.js} +4 -0
  7. package/dist/unstable-core-do-not-import/http/abortError.mjs +10 -0
  8. package/dist/unstable-core-do-not-import/stream/sse.d.ts.map +1 -1
  9. package/dist/unstable-core-do-not-import/stream/sse.js +12 -2
  10. package/dist/unstable-core-do-not-import/stream/sse.mjs +11 -1
  11. package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.d.ts +2 -2
  12. package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.d.ts.map +1 -1
  13. package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.js +5 -7
  14. package/dist/unstable-core-do-not-import/stream/utils/asyncIterable.mjs +5 -7
  15. package/dist/unstable-core-do-not-import.d.ts +1 -1
  16. package/dist/unstable-core-do-not-import.d.ts.map +1 -1
  17. package/dist/unstable-core-do-not-import.js +3 -2
  18. package/dist/unstable-core-do-not-import.mjs +1 -1
  19. package/package.json +2 -2
  20. package/src/unstable-core-do-not-import/http/{isAbortError.ts → abortError.ts} +4 -0
  21. package/src/unstable-core-do-not-import/stream/sse.ts +12 -1
  22. package/src/unstable-core-do-not-import/stream/utils/asyncIterable.ts +5 -8
  23. package/src/unstable-core-do-not-import.ts +1 -1
  24. package/dist/unstable-core-do-not-import/http/isAbortError.d.ts.map +0 -1
  25. package/dist/unstable-core-do-not-import/http/isAbortError.mjs +0 -7
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var isAbortError = require('../../unstable-core-do-not-import/http/isAbortError.js');
3
+ var abortError = require('../../unstable-core-do-not-import/http/abortError.js');
4
4
  require('../../vendor/unpromise/unpromise.js');
5
5
  require('../../unstable-core-do-not-import/stream/utils/disposable.js');
6
6
  require('../../unstable-core-do-not-import/rootConfig.js');
@@ -43,7 +43,7 @@ async function writeResponseBodyChunk(res, chunk) {
43
43
  signal: opts.signal
44
44
  });
45
45
  } catch (err) {
46
- if (isAbortError.isAbortError(err)) {
46
+ if (abortError.isAbortError(err)) {
47
47
  return;
48
48
  }
49
49
  throw err;
@@ -1,4 +1,4 @@
1
- import { isAbortError } from '../../unstable-core-do-not-import/http/isAbortError.mjs';
1
+ import { isAbortError } from '../../unstable-core-do-not-import/http/abortError.mjs';
2
2
  import '../../vendor/unpromise/unpromise.mjs';
3
3
  import '../../unstable-core-do-not-import/stream/utils/disposable.mjs';
4
4
  import '../../unstable-core-do-not-import/rootConfig.mjs';
@@ -1,7 +1,7 @@
1
1
  {
2
- "bundleSize": 198708,
3
- "bundleOrigSize": 230376,
4
- "bundleReduction": 13.75,
2
+ "bundleSize": 199019,
3
+ "bundleOrigSize": 230694,
4
+ "bundleReduction": 13.73,
5
5
  "modules": [
6
6
  {
7
7
  "id": "/src/unstable-core-do-not-import/http/resolveResponse.ts",
@@ -14,7 +14,7 @@
14
14
  "dependents": [
15
15
  "/src/unstable-core-do-not-import.ts"
16
16
  ],
17
- "percent": 10.61,
17
+ "percent": 10.6,
18
18
  "reduction": 0
19
19
  },
20
20
  {
@@ -30,7 +30,7 @@
30
30
  "dependents": [
31
31
  "/src/adapters/fastify/fastifyTRPCPlugin.ts"
32
32
  ],
33
- "percent": 10.14,
33
+ "percent": 10.13,
34
34
  "reduction": 0
35
35
  },
36
36
  {
@@ -47,13 +47,13 @@
47
47
  "/src/unstable-core-do-not-import.ts",
48
48
  "/src/unstable-core-do-not-import/http/resolveResponse.ts"
49
49
  ],
50
- "percent": 10.04,
50
+ "percent": 10.02,
51
51
  "reduction": 0
52
52
  },
53
53
  {
54
54
  "id": "/src/unstable-core-do-not-import/stream/sse.ts",
55
- "size": 12627,
56
- "origSize": 12452,
55
+ "size": 12951,
56
+ "origSize": 12706,
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.35,
67
+ "percent": 6.51,
68
68
  "reduction": 0
69
69
  },
70
70
  {
@@ -77,7 +77,7 @@
77
77
  ],
78
78
  "removedExports": [],
79
79
  "dependents": [],
80
- "percent": 6.12,
80
+ "percent": 6.11,
81
81
  "reduction": 11.62
82
82
  },
83
83
  {
@@ -98,7 +98,7 @@
98
98
  "/src/unstable-core-do-not-import/initTRPC.ts",
99
99
  "/src/unstable-core-do-not-import/http/contentType.ts"
100
100
  ],
101
- "percent": 5.11,
101
+ "percent": 5.1,
102
102
  "reduction": 29.61
103
103
  },
104
104
  {
@@ -112,7 +112,7 @@
112
112
  "dependents": [
113
113
  "/src/unstable-core-do-not-import/stream/jsonl.ts"
114
114
  ],
115
- "percent": 4.09,
115
+ "percent": 4.08,
116
116
  "reduction": 0
117
117
  },
118
118
  {
@@ -127,43 +127,43 @@
127
127
  "/src/unstable-core-do-not-import.ts",
128
128
  "/src/unstable-core-do-not-import/http/resolveResponse.ts"
129
129
  ],
130
- "percent": 3.97,
130
+ "percent": 3.96,
131
131
  "reduction": 0.83
132
132
  },
133
133
  {
134
- "id": "/src/unstable-core-do-not-import/stream/utils/asyncIterable.ts",
135
- "size": 5828,
136
- "origSize": 2704,
134
+ "id": "/src/unstable-core-do-not-import/procedureBuilder.ts",
135
+ "size": 5825,
136
+ "origSize": 16584,
137
137
  "renderedExports": [
138
- "iteratorResource",
139
- "withMaxDuration",
140
- "takeWithGrace"
138
+ "createBuilder"
141
139
  ],
142
140
  "removedExports": [],
143
141
  "dependents": [
144
142
  "/src/unstable-core-do-not-import.ts",
145
- "/src/adapters/ws.ts",
146
- "/src/unstable-core-do-not-import/stream/jsonl.ts",
147
- "/src/unstable-core-do-not-import/stream/sse.ts",
148
- "/src/unstable-core-do-not-import/stream/utils/withPing.ts"
143
+ "/src/unstable-core-do-not-import/initTRPC.ts"
149
144
  ],
150
145
  "percent": 2.93,
151
- "reduction": 0
146
+ "reduction": 64.88
152
147
  },
153
148
  {
154
- "id": "/src/unstable-core-do-not-import/procedureBuilder.ts",
155
- "size": 5825,
156
- "origSize": 16584,
149
+ "id": "/src/unstable-core-do-not-import/stream/utils/asyncIterable.ts",
150
+ "size": 5713,
151
+ "origSize": 2653,
157
152
  "renderedExports": [
158
- "createBuilder"
153
+ "iteratorResource",
154
+ "withMaxDuration",
155
+ "takeWithGrace"
159
156
  ],
160
157
  "removedExports": [],
161
158
  "dependents": [
162
159
  "/src/unstable-core-do-not-import.ts",
163
- "/src/unstable-core-do-not-import/initTRPC.ts"
160
+ "/src/adapters/ws.ts",
161
+ "/src/unstable-core-do-not-import/stream/jsonl.ts",
162
+ "/src/unstable-core-do-not-import/stream/sse.ts",
163
+ "/src/unstable-core-do-not-import/stream/utils/withPing.ts"
164
164
  ],
165
- "percent": 2.93,
166
- "reduction": 64.88
165
+ "percent": 2.87,
166
+ "reduction": 0
167
167
  },
168
168
  {
169
169
  "id": "/src/adapters/aws-lambda/getPlanner.ts",
@@ -228,7 +228,7 @@
228
228
  "/src/adapters/node-http/index.ts",
229
229
  "/src/adapters/node-http/nodeHTTPRequestHandler.ts"
230
230
  ],
231
- "percent": 2.04,
231
+ "percent": 2.03,
232
232
  "reduction": 6.82
233
233
  },
234
234
  {
@@ -246,7 +246,7 @@
246
246
  "dependents": [
247
247
  "/src/observable/index.ts"
248
248
  ],
249
- "percent": 1.97,
249
+ "percent": 1.96,
250
250
  "reduction": 1.66
251
251
  },
252
252
  {
@@ -362,7 +362,7 @@
362
362
  "/src/unstable-core-do-not-import/transformer.ts",
363
363
  "/src/unstable-core-do-not-import/middleware.ts",
364
364
  "/src/unstable-core-do-not-import/http/contentType.ts",
365
- "/src/unstable-core-do-not-import/http/isAbortError.ts",
365
+ "/src/unstable-core-do-not-import/http/abortError.ts",
366
366
  "/src/unstable-core-do-not-import/procedureBuilder.ts",
367
367
  "/src/unstable-core-do-not-import/stream/jsonl.ts",
368
368
  "/src/unstable-core-do-not-import/stream/sse.ts"
@@ -390,7 +390,7 @@
390
390
  "/src/unstable-core-do-not-import/procedureBuilder.ts",
391
391
  "/src/unstable-core-do-not-import/stream/sse.ts"
392
392
  ],
393
- "percent": 1.19,
393
+ "percent": 1.18,
394
394
  "reduction": 0
395
395
  },
396
396
  {
@@ -460,7 +460,7 @@
460
460
  },
461
461
  {
462
462
  "id": "/src/adapters/node-http/writeResponse.ts",
463
- "size": 2027,
463
+ "size": 2025,
464
464
  "origSize": 2105,
465
465
  "renderedExports": [
466
466
  "writeResponseBody",
@@ -471,7 +471,7 @@
471
471
  "/src/adapters/node-http/nodeHTTPRequestHandler.ts"
472
472
  ],
473
473
  "percent": 1.02,
474
- "reduction": 3.71
474
+ "reduction": 3.8
475
475
  },
476
476
  {
477
477
  "id": "/src/adapters/fastify/fastifyTRPCPlugin.ts",
@@ -604,7 +604,7 @@
604
604
  "/src/unstable-core-do-not-import.ts",
605
605
  "/src/unstable-core-do-not-import/http/contentType.ts"
606
606
  ],
607
- "percent": 0.56,
607
+ "percent": 0.55,
608
608
  "reduction": 15.08
609
609
  },
610
610
  {
@@ -749,7 +749,7 @@
749
749
  "/src/unstable-core-do-not-import/stream/utils/asyncIterable.ts",
750
750
  "/src/unstable-core-do-not-import/stream/utils/withPing.ts"
751
751
  ],
752
- "percent": 0.27,
752
+ "percent": 0.26,
753
753
  "reduction": 20.03
754
754
  },
755
755
  {
@@ -812,19 +812,21 @@
812
812
  "reduction": 36.26
813
813
  },
814
814
  {
815
- "id": "/src/unstable-core-do-not-import/http/isAbortError.ts",
816
- "size": 100,
817
- "origSize": 208,
815
+ "id": "/src/unstable-core-do-not-import/http/abortError.ts",
816
+ "size": 204,
817
+ "origSize": 325,
818
818
  "renderedExports": [
819
- "isAbortError"
819
+ "isAbortError",
820
+ "throwAbortError"
820
821
  ],
821
822
  "removedExports": [],
822
823
  "dependents": [
823
824
  "/src/unstable-core-do-not-import.ts",
824
- "/src/unstable-core-do-not-import/stream/sse.ts"
825
+ "/src/unstable-core-do-not-import/stream/sse.ts",
826
+ "/src/unstable-core-do-not-import/stream/utils/asyncIterable.ts"
825
827
  ],
826
- "percent": 0.05,
827
- "reduction": 51.92
828
+ "percent": 0.1,
829
+ "reduction": 37.23
828
830
  },
829
831
  {
830
832
  "id": "/src/unstable-core-do-not-import/procedure.ts",
@@ -902,16 +904,16 @@
902
904
  {
903
905
  "id": "/src/unstable-core-do-not-import.ts",
904
906
  "size": 0,
905
- "origSize": 2586,
907
+ "origSize": 2584,
906
908
  "renderedExports": [],
907
909
  "removedExports": [],
908
910
  "dependents": [
909
- "/src/adapters/next.ts",
910
911
  "/src/adapters/express.ts",
912
+ "/src/adapters/next.ts",
911
913
  "/src/adapters/standalone.ts",
912
914
  "/src/adapters/ws.ts",
913
- "/src/adapters/next-app-dir/nextAppDirCaller.ts",
914
915
  "/src/adapters/node-http/nodeHTTPRequestHandler.ts",
916
+ "/src/adapters/next-app-dir/nextAppDirCaller.ts",
915
917
  "/src/adapters/node-http/writeResponse.ts"
916
918
  ],
917
919
  "percent": 0,
@@ -966,8 +968,8 @@
966
968
  "renderedExports": [],
967
969
  "removedExports": [],
968
970
  "dependents": [
969
- "/src/adapters/next.ts",
970
971
  "/src/adapters/express.ts",
972
+ "/src/adapters/next.ts",
971
973
  "/src/adapters/standalone.ts",
972
974
  "/src/adapters/ws.ts",
973
975
  "/src/adapters/fastify/fastifyRequestHandler.ts"
@@ -1,4 +1,5 @@
1
1
  export declare function isAbortError(error: unknown): error is DOMException | Error | {
2
2
  name: 'AbortError';
3
3
  };
4
- //# sourceMappingURL=isAbortError.d.ts.map
4
+ export declare function throwAbortError(message?: string): never;
5
+ //# sourceMappingURL=abortError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abortError.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/abortError.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAC1B,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,YAAY,GAAG,KAAK,GAAG;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,CAExD;AAED,wBAAgB,eAAe,CAAC,OAAO,SAAe,GAAG,KAAK,CAE7D"}
@@ -5,5 +5,9 @@ var utils = require('../utils.js');
5
5
  function isAbortError(error) {
6
6
  return utils.isObject(error) && error['name'] === 'AbortError';
7
7
  }
8
+ function throwAbortError(message = 'AbortError') {
9
+ throw new DOMException(message, 'AbortError');
10
+ }
8
11
 
9
12
  exports.isAbortError = isAbortError;
13
+ exports.throwAbortError = throwAbortError;
@@ -0,0 +1,10 @@
1
+ import { isObject } from '../utils.mjs';
2
+
3
+ function isAbortError(error) {
4
+ return isObject(error) && error['name'] === 'AbortError';
5
+ }
6
+ function throwAbortError(message = 'AbortError') {
7
+ throw new DOMException(message, 'AbortError');
8
+ }
9
+
10
+ export { isAbortError, throwAbortError };
@@ -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,OA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ACd;AAED,UAAU,6BAA6B,CAAC,OAAO,SAAS,cAAc,CACpE,SAAQ,wBAAwB,CAAC,OAAO,CAAC;IACzC,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,EAAE,gBAAgB,CAAC;CAC3B;AAED,KAAK,oBAAoB,CAAC,OAAO,SAAS,cAAc,IACpD,wBAAwB,CAAC,OAAO,CAAC,GACjC,yBAAyB,CAAC,OAAO,CAAC,GAClC,8BAA8B,CAAC,OAAO,CAAC,GACvC,2BAA2B,CAAC,OAAO,CAAC,GACpC,wBAAwB,CAAC,OAAO,CAAC,GACjC,6BAA6B,CAAC,OAAO,CAAC,CAAC;AAE3C,MAAM,WAAW,wBAAwB,CAAC,OAAO,SAAS,cAAc;IACtE,GAAG,EAAE,MAAM,YAAY,CAAC,MAAM,CAAC,CAAC;IAChC,IAAI,EAAE,MACF,YAAY,CAAC,eAAe,CAAC,UAAU,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,GAChE,SAAS,CAAC;IACd,MAAM,EAAE,WAAW,CAAC;IACpB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,WAAW,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CACrC;AAED,UAAU,cAAc;IACtB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,WAAW,EAAE,eAAe,CAAC,cAAc,CAAC;CAC7C;AAgBD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,SAAS,cAAc,EAC9D,IAAI,EAAE,wBAAwB,CAAC,OAAO,CAAC,GACtC,aAAa,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAsK9C;AAED,eAAO,MAAM,UAAU;;;;;CAKb,CAAC"}
@@ -2,7 +2,7 @@
2
2
 
3
3
  var unpromise = require('../../vendor/unpromise/unpromise.js');
4
4
  var TRPCError = require('../error/TRPCError.js');
5
- var isAbortError = require('../http/isAbortError.js');
5
+ var abortError = require('../http/abortError.js');
6
6
  var utils = require('../utils.js');
7
7
  var tracked = require('./tracked.js');
8
8
  var asyncIterable = require('./utils/asyncIterable.js');
@@ -79,6 +79,7 @@ function _ts_dispose_resources(env) {
79
79
  const PING_EVENT = 'ping';
80
80
  const SERIALIZED_ERROR_EVENT = 'serialized-error';
81
81
  const CONNECTED_EVENT = 'connected';
82
+ const RETURN_EVENT = 'return';
82
83
  /**
83
84
  *
84
85
  * @see https://html.spec.whatwg.org/multipage/server-sent-events.html
@@ -140,8 +141,12 @@ const CONNECTED_EVENT = 'connected';
140
141
  async function* generatorWithErrorHandling() {
141
142
  try {
142
143
  yield* generator();
144
+ yield {
145
+ event: RETURN_EVENT,
146
+ data: ''
147
+ };
143
148
  } catch (cause) {
144
- if (isAbortError.isAbortError(cause)) {
149
+ if (abortError.isAbortError(cause)) {
145
150
  // ignore abort errors, send any other errors
146
151
  return;
147
152
  }
@@ -243,6 +248,11 @@ async function withTimeout(opts) {
243
248
  eventSource
244
249
  });
245
250
  });
251
+ eventSource.addEventListener(RETURN_EVENT, ()=>{
252
+ eventSource.close();
253
+ controller.close();
254
+ _es = null;
255
+ });
246
256
  eventSource.addEventListener('error', (event)=>{
247
257
  if (eventSource.readyState === EventSource.CLOSED) {
248
258
  controller.error(event);
@@ -1,6 +1,6 @@
1
1
  import { Unpromise } from '../../vendor/unpromise/unpromise.mjs';
2
2
  import { getTRPCErrorFromUnknown } from '../error/TRPCError.mjs';
3
- import { isAbortError } from '../http/isAbortError.mjs';
3
+ import { isAbortError } from '../http/abortError.mjs';
4
4
  import { run, identity } from '../utils.mjs';
5
5
  import { isTrackedEnvelope } from './tracked.mjs';
6
6
  import { takeWithGrace, withMaxDuration } from './utils/asyncIterable.mjs';
@@ -77,6 +77,7 @@ function _ts_dispose_resources(env) {
77
77
  const PING_EVENT = 'ping';
78
78
  const SERIALIZED_ERROR_EVENT = 'serialized-error';
79
79
  const CONNECTED_EVENT = 'connected';
80
+ const RETURN_EVENT = 'return';
80
81
  /**
81
82
  *
82
83
  * @see https://html.spec.whatwg.org/multipage/server-sent-events.html
@@ -138,6 +139,10 @@ const CONNECTED_EVENT = 'connected';
138
139
  async function* generatorWithErrorHandling() {
139
140
  try {
140
141
  yield* generator();
142
+ yield {
143
+ event: RETURN_EVENT,
144
+ data: ''
145
+ };
141
146
  } catch (cause) {
142
147
  if (isAbortError(cause)) {
143
148
  // ignore abort errors, send any other errors
@@ -241,6 +246,11 @@ async function withTimeout(opts) {
241
246
  eventSource
242
247
  });
243
248
  });
249
+ eventSource.addEventListener(RETURN_EVENT, ()=>{
250
+ eventSource.close();
251
+ controller.close();
252
+ _es = null;
253
+ });
244
254
  eventSource.addEventListener('error', (event)=>{
245
255
  if (eventSource.readyState === EventSource.CLOSED) {
246
256
  controller.error(event);
@@ -1,6 +1,6 @@
1
1
  export declare function iteratorResource<TYield, TReturn, TNext>(iterable: AsyncIterable<TYield, TReturn, TNext>): AsyncIterator<TYield, TReturn, TNext> & AsyncDisposable;
2
2
  /**
3
- * Derives a new {@link AsyncGenerator} based on {@link iterable}, that automatically stops after the specified duration.
3
+ * Derives a new {@link AsyncGenerator} based on {@link iterable}, that automatically aborts after the specified duration.
4
4
  */
5
5
  export declare function withMaxDuration<T>(iterable: AsyncIterable<T>, opts: {
6
6
  maxDurationMs: number;
@@ -8,7 +8,7 @@ export declare function withMaxDuration<T>(iterable: AsyncIterable<T>, opts: {
8
8
  /**
9
9
  * Derives a new {@link AsyncGenerator} based of {@link iterable}, that yields its first
10
10
  * {@link count} values. Then, a grace period of {@link gracePeriodMs} is started in which further
11
- * values may still come through. After this period, the generator stops.
11
+ * values may still come through. After this period, the generator aborts.
12
12
  */
13
13
  export declare function takeWithGrace<T>(iterable: AsyncIterable<T>, opts: {
14
14
  count: number;
@@ -1 +1 @@
1
- {"version":3,"file":"asyncIterable.d.ts","sourceRoot":"","sources":["../../../../src/unstable-core-do-not-import/stream/utils/asyncIterable.ts"],"names":[],"mappings":"AAIA,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,OAA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CAAC,CA6BnB"}
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var unpromise = require('../../../vendor/unpromise/unpromise.js');
4
+ var abortError = require('../../http/abortError.js');
4
5
  var disposable = require('./disposable.js');
5
6
  var timerResource = require('./timerResource.js');
6
7
 
@@ -76,7 +77,7 @@ function iteratorResource(iterable) {
76
77
  });
77
78
  }
78
79
  /**
79
- * Derives a new {@link AsyncGenerator} based on {@link iterable}, that automatically stops after the specified duration.
80
+ * Derives a new {@link AsyncGenerator} based on {@link iterable}, that automatically aborts after the specified duration.
80
81
  */ async function* withMaxDuration(iterable, opts) {
81
82
  const env = {
82
83
  stack: [],
@@ -98,8 +99,7 @@ function iteratorResource(iterable) {
98
99
  ]);
99
100
  if (result === timerResource.disposablePromiseTimerResult) {
100
101
  // cancelled due to timeout
101
- const res = await iterator.return?.();
102
- return res?.value;
102
+ abortError.throwAbortError();
103
103
  }
104
104
  if (result.done) {
105
105
  return result;
@@ -119,7 +119,7 @@ function iteratorResource(iterable) {
119
119
  /**
120
120
  * Derives a new {@link AsyncGenerator} based of {@link iterable}, that yields its first
121
121
  * {@link count} values. Then, a grace period of {@link gracePeriodMs} is started in which further
122
- * values may still come through. After this period, the generator stops.
122
+ * values may still come through. After this period, the generator aborts.
123
123
  */ async function* takeWithGrace(iterable, opts) {
124
124
  const env = {
125
125
  stack: [],
@@ -143,9 +143,7 @@ function iteratorResource(iterable) {
143
143
  timerPromise
144
144
  ]);
145
145
  if (result === timerResource.disposablePromiseTimerResult) {
146
- // cancelled
147
- const res = await iterator.return?.();
148
- return res?.value;
146
+ abortError.throwAbortError();
149
147
  }
150
148
  if (result.done) {
151
149
  return result.value;
@@ -1,4 +1,5 @@
1
1
  import { Unpromise } from '../../../vendor/unpromise/unpromise.mjs';
2
+ import { throwAbortError } from '../../http/abortError.mjs';
2
3
  import { makeAsyncResource } from './disposable.mjs';
3
4
  import { timerResource, disposablePromiseTimerResult } from './timerResource.mjs';
4
5
 
@@ -74,7 +75,7 @@ function iteratorResource(iterable) {
74
75
  });
75
76
  }
76
77
  /**
77
- * Derives a new {@link AsyncGenerator} based on {@link iterable}, that automatically stops after the specified duration.
78
+ * Derives a new {@link AsyncGenerator} based on {@link iterable}, that automatically aborts after the specified duration.
78
79
  */ async function* withMaxDuration(iterable, opts) {
79
80
  const env = {
80
81
  stack: [],
@@ -96,8 +97,7 @@ function iteratorResource(iterable) {
96
97
  ]);
97
98
  if (result === disposablePromiseTimerResult) {
98
99
  // cancelled due to timeout
99
- const res = await iterator.return?.();
100
- return res?.value;
100
+ throwAbortError();
101
101
  }
102
102
  if (result.done) {
103
103
  return result;
@@ -117,7 +117,7 @@ function iteratorResource(iterable) {
117
117
  /**
118
118
  * Derives a new {@link AsyncGenerator} based of {@link iterable}, that yields its first
119
119
  * {@link count} values. Then, a grace period of {@link gracePeriodMs} is started in which further
120
- * values may still come through. After this period, the generator stops.
120
+ * values may still come through. After this period, the generator aborts.
121
121
  */ async function* takeWithGrace(iterable, opts) {
122
122
  const env = {
123
123
  stack: [],
@@ -141,9 +141,7 @@ function iteratorResource(iterable) {
141
141
  timerPromise
142
142
  ]);
143
143
  if (result === disposablePromiseTimerResult) {
144
- // cancelled
145
- const res = await iterator.return?.();
146
- return res?.value;
144
+ throwAbortError();
147
145
  }
148
146
  if (result.done) {
149
147
  return result.value;
@@ -19,7 +19,7 @@ export * from './unstable-core-do-not-import/http/contentType';
19
19
  export * from './unstable-core-do-not-import/http/contentTypeParsers';
20
20
  export * from './unstable-core-do-not-import/http/formDataToObject';
21
21
  export * from './unstable-core-do-not-import/http/getHTTPStatusCode';
22
- export * from './unstable-core-do-not-import/http/isAbortError';
22
+ export * from './unstable-core-do-not-import/http/abortError';
23
23
  export * from './unstable-core-do-not-import/http/parseConnectionParams';
24
24
  export * from './unstable-core-do-not-import/http/resolveResponse';
25
25
  export * from './unstable-core-do-not-import/http/types';
@@ -1 +1 @@
1
- {"version":3,"file":"unstable-core-do-not-import.d.ts","sourceRoot":"","sources":["../src/unstable-core-do-not-import.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,cAAc,mDAAmD,CAAC;AAClE,cAAc,oDAAoD,CAAC;AACnE,cAAc,mDAAmD,CAAC;AAClE,cAAc,2CAA2C,CAAC;AAC1D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,mDAAmD,CAAC;AAClE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,gDAAgD,CAAC;AAC/D,cAAc,uDAAuD,CAAC;AACtE,cAAc,qDAAqD,CAAC;AACpE,cAAc,sDAAsD,CAAC;AACrE,cAAc,iDAAiD,CAAC;AAChE,cAAc,0DAA0D,CAAC;AACzE,cAAc,oDAAoD,CAAC;AACnE,cAAc,0CAA0C,CAAC;AACzD,cAAc,wCAAwC,CAAC;AACvD,cAAc,0CAA0C,CAAC;AACzD,cAAc,sCAAsC,CAAC;AACrD,cAAc,yCAAyC,CAAC;AACxD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,0CAA0C,CAAC;AACzD,cAAc,sCAAsC,CAAC;AACrD,cAAc,mCAAmC,CAAC;AAClD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,gDAAgD,CAAC;AAC/D,cAAc,0CAA0C,CAAC;AACzD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,2DAA2D,CAAC;AAC1E,cAAc,uDAAuD,CAAC;AACtE,cAAc,0DAA0D,CAAC;AACzE,cAAc,2CAA2C,CAAC;AAC1D,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"unstable-core-do-not-import.d.ts","sourceRoot":"","sources":["../src/unstable-core-do-not-import.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,cAAc,mDAAmD,CAAC;AAClE,cAAc,oDAAoD,CAAC;AACnE,cAAc,mDAAmD,CAAC;AAClE,cAAc,2CAA2C,CAAC;AAC1D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,mDAAmD,CAAC;AAClE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,gDAAgD,CAAC;AAC/D,cAAc,uDAAuD,CAAC;AACtE,cAAc,qDAAqD,CAAC;AACpE,cAAc,sDAAsD,CAAC;AACrE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,0DAA0D,CAAC;AACzE,cAAc,oDAAoD,CAAC;AACnE,cAAc,0CAA0C,CAAC;AACzD,cAAc,wCAAwC,CAAC;AACvD,cAAc,0CAA0C,CAAC;AACzD,cAAc,sCAAsC,CAAC;AACrD,cAAc,yCAAyC,CAAC;AACxD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,0CAA0C,CAAC;AACzD,cAAc,sCAAsC,CAAC;AACrD,cAAc,mCAAmC,CAAC;AAClD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,gDAAgD,CAAC;AAC/D,cAAc,0CAA0C,CAAC;AACzD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,2DAA2D,CAAC;AAC1E,cAAc,uDAAuD,CAAC;AACtE,cAAc,0DAA0D,CAAC;AACzE,cAAc,2CAA2C,CAAC;AAC1D,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,oBAAoB,CAAC"}
@@ -8,7 +8,7 @@ var contentType = require('./unstable-core-do-not-import/http/contentType.js');
8
8
  var contentTypeParsers = require('./unstable-core-do-not-import/http/contentTypeParsers.js');
9
9
  var formDataToObject = require('./unstable-core-do-not-import/http/formDataToObject.js');
10
10
  var getHTTPStatusCode = require('./unstable-core-do-not-import/http/getHTTPStatusCode.js');
11
- var isAbortError = require('./unstable-core-do-not-import/http/isAbortError.js');
11
+ var abortError = require('./unstable-core-do-not-import/http/abortError.js');
12
12
  var parseConnectionParams = require('./unstable-core-do-not-import/http/parseConnectionParams.js');
13
13
  var resolveResponse = require('./unstable-core-do-not-import/http/resolveResponse.js');
14
14
  var initTRPC = require('./unstable-core-do-not-import/initTRPC.js');
@@ -49,7 +49,8 @@ exports.getHTTPStatusCode = getHTTPStatusCode.getHTTPStatusCode;
49
49
  exports.getHTTPStatusCodeFromError = getHTTPStatusCode.getHTTPStatusCodeFromError;
50
50
  exports.getStatusCodeFromKey = getHTTPStatusCode.getStatusCodeFromKey;
51
51
  exports.getStatusKeyFromCode = getHTTPStatusCode.getStatusKeyFromCode;
52
- exports.isAbortError = isAbortError.isAbortError;
52
+ exports.isAbortError = abortError.isAbortError;
53
+ exports.throwAbortError = abortError.throwAbortError;
53
54
  exports.parseConnectionParamsFromString = parseConnectionParams.parseConnectionParamsFromString;
54
55
  exports.parseConnectionParamsFromUnknown = parseConnectionParams.parseConnectionParamsFromUnknown;
55
56
  exports.resolveResponse = resolveResponse.resolveResponse;
@@ -6,7 +6,7 @@ export { getRequestInfo } from './unstable-core-do-not-import/http/contentType.m
6
6
  export { octetInputParser } from './unstable-core-do-not-import/http/contentTypeParsers.mjs';
7
7
  export { formDataToObject } from './unstable-core-do-not-import/http/formDataToObject.mjs';
8
8
  export { HTTP_CODE_TO_JSONRPC2, JSONRPC2_TO_HTTP_CODE, getHTTPStatusCode, getHTTPStatusCodeFromError, getStatusCodeFromKey, getStatusKeyFromCode } from './unstable-core-do-not-import/http/getHTTPStatusCode.mjs';
9
- export { isAbortError } from './unstable-core-do-not-import/http/isAbortError.mjs';
9
+ export { isAbortError, throwAbortError } from './unstable-core-do-not-import/http/abortError.mjs';
10
10
  export { parseConnectionParamsFromString, parseConnectionParamsFromUnknown } from './unstable-core-do-not-import/http/parseConnectionParams.mjs';
11
11
  export { resolveResponse } from './unstable-core-do-not-import/http/resolveResponse.mjs';
12
12
  export { initTRPC } from './unstable-core-do-not-import/initTRPC.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/server",
3
- "version": "11.0.0-rc.748+b19e7e9a6",
3
+ "version": "11.0.0-rc.750+3ade8efd4",
4
4
  "description": "The tRPC server library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -152,5 +152,5 @@
152
152
  "peerDependencies": {
153
153
  "typescript": ">=5.7.2"
154
154
  },
155
- "gitHead": "b19e7e9a640511f49de05bcd4436dc0a514f5e0f"
155
+ "gitHead": "3ade8efd48bf1d507c4ccbd4381c8a5923dbc375"
156
156
  }
@@ -5,3 +5,7 @@ export function isAbortError(
5
5
  ): error is DOMException | Error | { name: 'AbortError' } {
6
6
  return isObject(error) && error['name'] === 'AbortError';
7
7
  }
8
+
9
+ export function throwAbortError(message = 'AbortError'): never {
10
+ throw new DOMException(message, 'AbortError');
11
+ }
@@ -1,6 +1,6 @@
1
1
  import { Unpromise } from '../../vendor/unpromise';
2
2
  import { getTRPCErrorFromUnknown } from '../error/TRPCError';
3
- import { isAbortError } from '../http/isAbortError';
3
+ import { isAbortError } from '../http/abortError';
4
4
  import type { MaybePromise } from '../types';
5
5
  import { identity, run } from '../utils';
6
6
  import type { EventSourceLike } from './sse.types';
@@ -70,6 +70,7 @@ export interface SSEStreamProducerOptions<TValue = unknown> {
70
70
  const PING_EVENT = 'ping';
71
71
  const SERIALIZED_ERROR_EVENT = 'serialized-error';
72
72
  const CONNECTED_EVENT = 'connected';
73
+ const RETURN_EVENT = 'return';
73
74
 
74
75
  interface SSEvent {
75
76
  id?: string;
@@ -161,6 +162,11 @@ export function sseStreamProducer<TValue = unknown>(
161
162
  async function* generatorWithErrorHandling(): AsyncIterable<SSEvent, void> {
162
163
  try {
163
164
  yield* generator();
165
+
166
+ yield {
167
+ event: RETURN_EVENT,
168
+ data: '',
169
+ };
164
170
  } catch (cause) {
165
171
  if (isAbortError(cause)) {
166
172
  // ignore abort errors, send any other errors
@@ -334,6 +340,11 @@ export function sseStreamConsumer<TConfig extends ConsumerConfig>(
334
340
  eventSource,
335
341
  });
336
342
  });
343
+ eventSource.addEventListener(RETURN_EVENT, () => {
344
+ eventSource.close();
345
+ controller.close();
346
+ _es = null;
347
+ });
337
348
  eventSource.addEventListener('error', (event) => {
338
349
  if (eventSource.readyState === EventSource.CLOSED) {
339
350
  controller.error(event);
@@ -1,4 +1,5 @@
1
1
  import { Unpromise } from '../../../vendor/unpromise';
2
+ import { throwAbortError } from '../../http/abortError';
2
3
  import { makeAsyncResource } from './disposable';
3
4
  import { disposablePromiseTimerResult, timerResource } from './timerResource';
4
5
 
@@ -12,7 +13,7 @@ export function iteratorResource<TYield, TReturn, TNext>(
12
13
  });
13
14
  }
14
15
  /**
15
- * Derives a new {@link AsyncGenerator} based on {@link iterable}, that automatically stops after the specified duration.
16
+ * Derives a new {@link AsyncGenerator} based on {@link iterable}, that automatically aborts after the specified duration.
16
17
  */
17
18
  export async function* withMaxDuration<T>(
18
19
  iterable: AsyncIterable<T>,
@@ -31,9 +32,7 @@ export async function* withMaxDuration<T>(
31
32
  result = await Unpromise.race([iterator.next(), timerPromise]);
32
33
  if (result === disposablePromiseTimerResult) {
33
34
  // cancelled due to timeout
34
-
35
- const res = await iterator.return?.();
36
- return res?.value;
35
+ throwAbortError();
37
36
  }
38
37
  if (result.done) {
39
38
  return result;
@@ -47,7 +46,7 @@ export async function* withMaxDuration<T>(
47
46
  /**
48
47
  * Derives a new {@link AsyncGenerator} based of {@link iterable}, that yields its first
49
48
  * {@link count} values. Then, a grace period of {@link gracePeriodMs} is started in which further
50
- * values may still come through. After this period, the generator stops.
49
+ * values may still come through. After this period, the generator aborts.
51
50
  */
52
51
  export async function* takeWithGrace<T>(
53
52
  iterable: AsyncIterable<T>,
@@ -72,9 +71,7 @@ export async function* takeWithGrace<T>(
72
71
  while (true) {
73
72
  result = await Unpromise.race([iterator.next(), timerPromise]);
74
73
  if (result === disposablePromiseTimerResult) {
75
- // cancelled
76
- const res = await iterator.return?.();
77
- return res?.value;
74
+ throwAbortError();
78
75
  }
79
76
  if (result.done) {
80
77
  return result.value;
@@ -19,7 +19,7 @@ export * from './unstable-core-do-not-import/http/contentType';
19
19
  export * from './unstable-core-do-not-import/http/contentTypeParsers';
20
20
  export * from './unstable-core-do-not-import/http/formDataToObject';
21
21
  export * from './unstable-core-do-not-import/http/getHTTPStatusCode';
22
- export * from './unstable-core-do-not-import/http/isAbortError';
22
+ export * from './unstable-core-do-not-import/http/abortError';
23
23
  export * from './unstable-core-do-not-import/http/parseConnectionParams';
24
24
  export * from './unstable-core-do-not-import/http/resolveResponse';
25
25
  export * from './unstable-core-do-not-import/http/types';
@@ -1 +0,0 @@
1
- {"version":3,"file":"isAbortError.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/isAbortError.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAC1B,KAAK,EAAE,OAAO,GACb,KAAK,IAAI,YAAY,GAAG,KAAK,GAAG;IAAE,IAAI,EAAE,YAAY,CAAA;CAAE,CAExD"}
@@ -1,7 +0,0 @@
1
- import { isObject } from '../utils.mjs';
2
-
3
- function isAbortError(error) {
4
- return isObject(error) && error['name'] === 'AbortError';
5
- }
6
-
7
- export { isAbortError };