@trpc/server 11.0.0-alpha-tmp-issues-5851-take-two.448 → 11.0.0-alpha-tmp-issues-5851-take-two.451
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle-analysis.json +33 -33
- package/dist/unstable-core-do-not-import/stream/jsonl.d.ts +7 -3
- package/dist/unstable-core-do-not-import/stream/jsonl.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/stream/jsonl.js +35 -33
- package/dist/unstable-core-do-not-import/stream/jsonl.mjs +35 -33
- package/package.json +2 -2
- package/src/unstable-core-do-not-import/stream/jsonl.ts +48 -42
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction": 27.
|
|
2
|
+
"bundleSize": 131734,
|
|
3
|
+
"bundleOrigSize": 181107,
|
|
4
|
+
"bundleReduction": 27.26,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/unstable-core-do-not-import/stream/jsonl.ts",
|
|
8
|
-
"size":
|
|
9
|
-
"origSize":
|
|
8
|
+
"size": 17622,
|
|
9
|
+
"origSize": 18419,
|
|
10
10
|
"renderedExports": [
|
|
11
11
|
"isPromise",
|
|
12
12
|
"jsonlStreamProducer",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"/src/unstable-core-do-not-import.ts",
|
|
18
18
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
19
19
|
],
|
|
20
|
-
"percent": 13.
|
|
21
|
-
"reduction":
|
|
20
|
+
"percent": 13.38,
|
|
21
|
+
"reduction": 4.33
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
"id": "/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dependents": [
|
|
32
32
|
"/src/unstable-core-do-not-import.ts"
|
|
33
33
|
],
|
|
34
|
-
"percent": 12.
|
|
34
|
+
"percent": 12.96,
|
|
35
35
|
"reduction": 0
|
|
36
36
|
},
|
|
37
37
|
{
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"dependents": [
|
|
47
47
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
48
48
|
],
|
|
49
|
-
"percent": 10.
|
|
49
|
+
"percent": 10.84,
|
|
50
50
|
"reduction": 0
|
|
51
51
|
},
|
|
52
52
|
{
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"/src/unstable-core-do-not-import.ts",
|
|
62
62
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
63
63
|
],
|
|
64
|
-
"percent": 5.
|
|
64
|
+
"percent": 5.76,
|
|
65
65
|
"reduction": 0
|
|
66
66
|
},
|
|
67
67
|
{
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"/src/unstable-core-do-not-import.ts",
|
|
80
80
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
81
81
|
],
|
|
82
|
-
"percent": 4.
|
|
82
|
+
"percent": 4.84,
|
|
83
83
|
"reduction": 39.77
|
|
84
84
|
},
|
|
85
85
|
{
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"/src/unstable-core-do-not-import.ts",
|
|
95
95
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
96
96
|
],
|
|
97
|
-
"percent": 4.
|
|
97
|
+
"percent": 4.8,
|
|
98
98
|
"reduction": 60.06
|
|
99
99
|
},
|
|
100
100
|
{
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
"dependents": [
|
|
128
128
|
"/src/adapters/aws-lambda/index.ts"
|
|
129
129
|
],
|
|
130
|
-
"percent": 4.
|
|
130
|
+
"percent": 4.11,
|
|
131
131
|
"reduction": 11.38
|
|
132
132
|
},
|
|
133
133
|
{
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
148
148
|
"/src/observable/operators.ts"
|
|
149
149
|
],
|
|
150
|
-
"percent": 3.
|
|
150
|
+
"percent": 3.4,
|
|
151
151
|
"reduction": 0
|
|
152
152
|
},
|
|
153
153
|
{
|
|
@@ -197,7 +197,7 @@
|
|
|
197
197
|
"/src/unstable-core-do-not-import/initTRPC.ts",
|
|
198
198
|
"/src/unstable-core-do-not-import/router.ts"
|
|
199
199
|
],
|
|
200
|
-
"percent": 2.
|
|
200
|
+
"percent": 2.08,
|
|
201
201
|
"reduction": 45.94
|
|
202
202
|
},
|
|
203
203
|
{
|
|
@@ -245,7 +245,7 @@
|
|
|
245
245
|
"/src/unstable-core-do-not-import/initTRPC.ts",
|
|
246
246
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
247
247
|
],
|
|
248
|
-
"percent":
|
|
248
|
+
"percent": 1.99,
|
|
249
249
|
"reduction": 55.5
|
|
250
250
|
},
|
|
251
251
|
{
|
|
@@ -418,12 +418,12 @@
|
|
|
418
418
|
"/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
|
|
419
419
|
"/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
|
|
420
420
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
421
|
-
"/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
|
|
422
421
|
"/src/unstable-core-do-not-import/error/TRPCError.ts",
|
|
423
422
|
"/src/unstable-core-do-not-import/stream/sse.ts",
|
|
424
423
|
"/src/unstable-core-do-not-import/transformer.ts",
|
|
425
424
|
"/src/unstable-core-do-not-import/middleware.ts",
|
|
426
425
|
"/src/unstable-core-do-not-import/router.ts",
|
|
426
|
+
"/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
|
|
427
427
|
"/src/unstable-core-do-not-import/http/contentType.ts",
|
|
428
428
|
"/src/unstable-core-do-not-import/procedureBuilder.ts",
|
|
429
429
|
"/src/unstable-core-do-not-import/stream/jsonl.ts"
|
|
@@ -473,7 +473,7 @@
|
|
|
473
473
|
"dependents": [
|
|
474
474
|
"/src/unstable-core-do-not-import.ts"
|
|
475
475
|
],
|
|
476
|
-
"percent": 0.
|
|
476
|
+
"percent": 0.8,
|
|
477
477
|
"reduction": 0
|
|
478
478
|
},
|
|
479
479
|
{
|
|
@@ -488,7 +488,7 @@
|
|
|
488
488
|
"/src/unstable-core-do-not-import.ts",
|
|
489
489
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
490
490
|
],
|
|
491
|
-
"percent": 0.
|
|
491
|
+
"percent": 0.78,
|
|
492
492
|
"reduction": 58.57
|
|
493
493
|
},
|
|
494
494
|
{
|
|
@@ -591,7 +591,7 @@
|
|
|
591
591
|
],
|
|
592
592
|
"removedExports": [],
|
|
593
593
|
"dependents": [],
|
|
594
|
-
"percent": 0.
|
|
594
|
+
"percent": 0.39,
|
|
595
595
|
"reduction": 67.09
|
|
596
596
|
},
|
|
597
597
|
{
|
|
@@ -720,16 +720,6 @@
|
|
|
720
720
|
"percent": 0,
|
|
721
721
|
"reduction": 100
|
|
722
722
|
},
|
|
723
|
-
{
|
|
724
|
-
"id": "/src/rpc.ts",
|
|
725
|
-
"size": 0,
|
|
726
|
-
"origSize": 36,
|
|
727
|
-
"renderedExports": [],
|
|
728
|
-
"removedExports": [],
|
|
729
|
-
"dependents": [],
|
|
730
|
-
"percent": 0,
|
|
731
|
-
"reduction": 100
|
|
732
|
-
},
|
|
733
723
|
{
|
|
734
724
|
"id": "/src/index.ts",
|
|
735
725
|
"size": 0,
|
|
@@ -741,9 +731,9 @@
|
|
|
741
731
|
"reduction": 100
|
|
742
732
|
},
|
|
743
733
|
{
|
|
744
|
-
"id": "/src/
|
|
734
|
+
"id": "/src/rpc.ts",
|
|
745
735
|
"size": 0,
|
|
746
|
-
"origSize":
|
|
736
|
+
"origSize": 36,
|
|
747
737
|
"renderedExports": [],
|
|
748
738
|
"removedExports": [],
|
|
749
739
|
"dependents": [],
|
|
@@ -763,6 +753,16 @@
|
|
|
763
753
|
"percent": 0,
|
|
764
754
|
"reduction": 100
|
|
765
755
|
},
|
|
756
|
+
{
|
|
757
|
+
"id": "/src/shared.ts",
|
|
758
|
+
"size": 0,
|
|
759
|
+
"origSize": 653,
|
|
760
|
+
"renderedExports": [],
|
|
761
|
+
"removedExports": [],
|
|
762
|
+
"dependents": [],
|
|
763
|
+
"percent": 0,
|
|
764
|
+
"reduction": 100
|
|
765
|
+
},
|
|
766
766
|
{
|
|
767
767
|
"id": "/src/adapters/next-app-dir.ts",
|
|
768
768
|
"size": 0,
|
|
@@ -813,8 +813,8 @@
|
|
|
813
813
|
"removedExports": [],
|
|
814
814
|
"dependents": [
|
|
815
815
|
"/src/adapters/express.ts",
|
|
816
|
-
"/src/adapters/next.ts",
|
|
817
816
|
"/src/adapters/standalone.ts",
|
|
817
|
+
"/src/adapters/next.ts",
|
|
818
818
|
"/src/adapters/fastify/fastifyRequestHandler.ts"
|
|
819
819
|
],
|
|
820
820
|
"percent": 0,
|
|
@@ -56,9 +56,10 @@ type ChunkData = PromiseChunk | IterableChunk;
|
|
|
56
56
|
export declare function isPromise(value: unknown): value is Promise<unknown>;
|
|
57
57
|
type Serialize = (value: any) => any;
|
|
58
58
|
type Deserialize = (value: any) => any;
|
|
59
|
+
type PathArray = readonly (string | number)[];
|
|
59
60
|
export type ProducerOnError = (opts: {
|
|
60
61
|
error: unknown;
|
|
61
|
-
path:
|
|
62
|
+
path: PathArray;
|
|
62
63
|
}) => void;
|
|
63
64
|
export interface ProducerOptions {
|
|
64
65
|
serialize?: Serialize;
|
|
@@ -66,7 +67,7 @@ export interface ProducerOptions {
|
|
|
66
67
|
onError?: ProducerOnError;
|
|
67
68
|
formatError?: (opts: {
|
|
68
69
|
error: unknown;
|
|
69
|
-
path:
|
|
70
|
+
path: PathArray;
|
|
70
71
|
}) => unknown;
|
|
71
72
|
maxDepth?: number;
|
|
72
73
|
}
|
|
@@ -93,7 +94,10 @@ export declare function jsonlStreamConsumer<THead>(opts: {
|
|
|
93
94
|
error: unknown;
|
|
94
95
|
}) => Error;
|
|
95
96
|
}): Promise<readonly [Awaited<THead>, {
|
|
96
|
-
readonly controllers: Map<ChunkIndex,
|
|
97
|
+
readonly controllers: Map<ChunkIndex, {
|
|
98
|
+
controller: ReadableStreamDefaultController<ChunkData | StreamInterruptedError>;
|
|
99
|
+
abortController: AbortController;
|
|
100
|
+
}>;
|
|
97
101
|
}]>;
|
|
98
102
|
export {};
|
|
99
103
|
//# sourceMappingURL=jsonl.d.ts.map
|
|
@@ -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,QAAA,MAAM,wBAAwB,IAAI,CAAC;AACnC,KAAK,wBAAwB,GAAG,OAAO,wBAAwB,CAAC;AAChE,QAAA,MAAM,uBAAuB,IAAI,CAAC;AAClC,KAAK,uBAAuB,GAAG,OAAO,uBAAuB,CAAC;AAE9D,QAAA,MAAM,0BAA0B,IAAI,CAAC;AACrC,KAAK,0BAA0B,GAAG,OAAO,0BAA0B,CAAC;AACpE,QAAA,MAAM,2BAA2B,IAAI,CAAC;AACtC,KAAK,2BAA2B,GAAG,OAAO,2BAA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E,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;AAuLD;;;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;CACnD;;;yBAoBoB,eAAe;;IA6MnC"}
|
|
@@ -321,7 +321,7 @@ function createConsumerStream(from) {
|
|
|
321
321
|
* @see https://jsonlines.org/
|
|
322
322
|
*/ async function jsonlStreamConsumer(opts) {
|
|
323
323
|
const { deserialize =(v)=>v } = opts;
|
|
324
|
-
const
|
|
324
|
+
const streamAbortController = new AbortController();
|
|
325
325
|
let source = createConsumerStream(opts.from);
|
|
326
326
|
if (deserialize) {
|
|
327
327
|
source = source.pipeThrough(new TransformStream({
|
|
@@ -333,21 +333,18 @@ function createConsumerStream(from) {
|
|
|
333
333
|
let headDeferred = createDeferred.createDeferred();
|
|
334
334
|
const chunkDeferred = new Map();
|
|
335
335
|
const controllers = new Map();
|
|
336
|
-
|
|
337
|
-
controllers.delete(idx);
|
|
338
|
-
if (controllers.size === 0 && chunkDeferred.size === 0) {
|
|
339
|
-
// nothing can be listening to the stream anymore
|
|
340
|
-
abortController.abort();
|
|
341
|
-
}
|
|
342
|
-
};
|
|
343
|
-
function hydrateChunkDefinition(value) {
|
|
336
|
+
function hydrateChunkDefinition(value, path) {
|
|
344
337
|
const [_path, type, chunkId] = value;
|
|
345
338
|
const { readable , controller } = createReadableStream.createReadableStream();
|
|
346
|
-
|
|
339
|
+
const wrapper = {
|
|
340
|
+
controller,
|
|
341
|
+
abortController: new AbortController()
|
|
342
|
+
};
|
|
343
|
+
controllers.set(chunkId, wrapper);
|
|
347
344
|
// resolve chunk deferred if it exists
|
|
348
345
|
const deferred = chunkDeferred.get(chunkId);
|
|
349
346
|
if (deferred) {
|
|
350
|
-
deferred.resolve(
|
|
347
|
+
deferred.resolve(wrapper);
|
|
351
348
|
chunkDeferred.delete(chunkId);
|
|
352
349
|
}
|
|
353
350
|
switch(type){
|
|
@@ -369,7 +366,7 @@ function createConsumerStream(from) {
|
|
|
369
366
|
const [_chunkId, status, data] = value;
|
|
370
367
|
switch(status){
|
|
371
368
|
case PROMISE_STATUS_FULFILLED:
|
|
372
|
-
resolve(hydrate(data));
|
|
369
|
+
resolve(hydrate(data, path));
|
|
373
370
|
break;
|
|
374
371
|
case PROMISE_STATUS_REJECTED:
|
|
375
372
|
reject(opts.formatError?.({
|
|
@@ -395,7 +392,7 @@ function createConsumerStream(from) {
|
|
|
395
392
|
throw value;
|
|
396
393
|
}
|
|
397
394
|
if (done) {
|
|
398
|
-
|
|
395
|
+
controllers.delete(chunkId);
|
|
399
396
|
return {
|
|
400
397
|
done: true,
|
|
401
398
|
value: undefined
|
|
@@ -406,26 +403,26 @@ function createConsumerStream(from) {
|
|
|
406
403
|
case ASYNC_ITERABLE_STATUS_VALUE:
|
|
407
404
|
return {
|
|
408
405
|
done: false,
|
|
409
|
-
value: hydrate(data)
|
|
406
|
+
value: hydrate(data, path)
|
|
410
407
|
};
|
|
411
408
|
case ASYNC_ITERABLE_STATUS_DONE:
|
|
412
|
-
|
|
409
|
+
controllers.delete(chunkId);
|
|
413
410
|
return {
|
|
414
411
|
done: true,
|
|
415
412
|
value: undefined
|
|
416
413
|
};
|
|
417
414
|
case ASYNC_ITERABLE_STATUS_ERROR:
|
|
418
|
-
|
|
415
|
+
controllers.delete(chunkId);
|
|
419
416
|
throw opts.formatError?.({
|
|
420
417
|
error: data
|
|
421
418
|
}) ?? new AsyncError(data);
|
|
422
419
|
}
|
|
423
420
|
},
|
|
424
421
|
return: async ()=>{
|
|
425
|
-
|
|
426
|
-
if (
|
|
427
|
-
// nothing
|
|
428
|
-
|
|
422
|
+
wrapper.abortController.abort();
|
|
423
|
+
if (chunkDeferred.size === 0 && Array.from(controllers.values()).every((it)=>it.abortController.signal.aborted)) {
|
|
424
|
+
// nothing is listening to the stream anymore
|
|
425
|
+
streamAbortController.abort();
|
|
429
426
|
}
|
|
430
427
|
return {
|
|
431
428
|
done: true,
|
|
@@ -439,15 +436,18 @@ function createConsumerStream(from) {
|
|
|
439
436
|
}
|
|
440
437
|
}
|
|
441
438
|
}
|
|
442
|
-
function hydrate(value) {
|
|
439
|
+
function hydrate(value, path) {
|
|
443
440
|
const [[data], ...asyncProps] = value;
|
|
444
441
|
for (const value1 of asyncProps){
|
|
445
|
-
const
|
|
446
|
-
const
|
|
447
|
-
|
|
442
|
+
const [key] = value1;
|
|
443
|
+
const hydrated = hydrateChunkDefinition(value1, key === null ? path : [
|
|
444
|
+
...path,
|
|
445
|
+
key
|
|
446
|
+
]);
|
|
447
|
+
if (key === null) {
|
|
448
448
|
return hydrated;
|
|
449
449
|
}
|
|
450
|
-
data[
|
|
450
|
+
data[key] = hydrated;
|
|
451
451
|
}
|
|
452
452
|
return data;
|
|
453
453
|
}
|
|
@@ -458,7 +458,7 @@ function createConsumerStream(from) {
|
|
|
458
458
|
deferred.reject(error);
|
|
459
459
|
}
|
|
460
460
|
chunkDeferred.clear();
|
|
461
|
-
for (const controller of controllers.values()){
|
|
461
|
+
for (const { controller } of controllers.values()){
|
|
462
462
|
controller.enqueue(error);
|
|
463
463
|
controller.close();
|
|
464
464
|
}
|
|
@@ -466,15 +466,17 @@ function createConsumerStream(from) {
|
|
|
466
466
|
};
|
|
467
467
|
source.pipeTo(new WritableStream({
|
|
468
468
|
start (controller) {
|
|
469
|
-
|
|
470
|
-
controller.error(
|
|
469
|
+
streamAbortController.signal.addEventListener('abort', ()=>{
|
|
470
|
+
controller.error(streamAbortController.signal.reason);
|
|
471
471
|
});
|
|
472
472
|
},
|
|
473
473
|
async write (chunkOrHead) {
|
|
474
474
|
if (headDeferred) {
|
|
475
475
|
const head = chunkOrHead;
|
|
476
476
|
for (const [key, value] of Object.entries(chunkOrHead)){
|
|
477
|
-
const parsed = hydrate(value
|
|
477
|
+
const parsed = hydrate(value, [
|
|
478
|
+
key
|
|
479
|
+
]);
|
|
478
480
|
head[key] = parsed;
|
|
479
481
|
}
|
|
480
482
|
headDeferred.resolve(head);
|
|
@@ -483,16 +485,16 @@ function createConsumerStream(from) {
|
|
|
483
485
|
}
|
|
484
486
|
const chunk = chunkOrHead;
|
|
485
487
|
const [idx] = chunk;
|
|
486
|
-
let
|
|
487
|
-
if (!
|
|
488
|
+
let wrapper = controllers.get(idx);
|
|
489
|
+
if (!wrapper) {
|
|
488
490
|
let deferred = chunkDeferred.get(idx);
|
|
489
491
|
if (!deferred) {
|
|
490
492
|
deferred = createDeferred.createDeferred();
|
|
491
493
|
chunkDeferred.set(idx, deferred);
|
|
492
494
|
}
|
|
493
|
-
|
|
495
|
+
wrapper = await deferred.promise;
|
|
494
496
|
}
|
|
495
|
-
controller.enqueue(chunk);
|
|
497
|
+
wrapper.controller.enqueue(chunk);
|
|
496
498
|
},
|
|
497
499
|
close: closeOrAbort,
|
|
498
500
|
abort: closeOrAbort
|
|
@@ -319,7 +319,7 @@ function createConsumerStream(from) {
|
|
|
319
319
|
* @see https://jsonlines.org/
|
|
320
320
|
*/ async function jsonlStreamConsumer(opts) {
|
|
321
321
|
const { deserialize =(v)=>v } = opts;
|
|
322
|
-
const
|
|
322
|
+
const streamAbortController = new AbortController();
|
|
323
323
|
let source = createConsumerStream(opts.from);
|
|
324
324
|
if (deserialize) {
|
|
325
325
|
source = source.pipeThrough(new TransformStream({
|
|
@@ -331,21 +331,18 @@ function createConsumerStream(from) {
|
|
|
331
331
|
let headDeferred = createDeferred();
|
|
332
332
|
const chunkDeferred = new Map();
|
|
333
333
|
const controllers = new Map();
|
|
334
|
-
|
|
335
|
-
controllers.delete(idx);
|
|
336
|
-
if (controllers.size === 0 && chunkDeferred.size === 0) {
|
|
337
|
-
// nothing can be listening to the stream anymore
|
|
338
|
-
abortController.abort();
|
|
339
|
-
}
|
|
340
|
-
};
|
|
341
|
-
function hydrateChunkDefinition(value) {
|
|
334
|
+
function hydrateChunkDefinition(value, path) {
|
|
342
335
|
const [_path, type, chunkId] = value;
|
|
343
336
|
const { readable , controller } = createReadableStream();
|
|
344
|
-
|
|
337
|
+
const wrapper = {
|
|
338
|
+
controller,
|
|
339
|
+
abortController: new AbortController()
|
|
340
|
+
};
|
|
341
|
+
controllers.set(chunkId, wrapper);
|
|
345
342
|
// resolve chunk deferred if it exists
|
|
346
343
|
const deferred = chunkDeferred.get(chunkId);
|
|
347
344
|
if (deferred) {
|
|
348
|
-
deferred.resolve(
|
|
345
|
+
deferred.resolve(wrapper);
|
|
349
346
|
chunkDeferred.delete(chunkId);
|
|
350
347
|
}
|
|
351
348
|
switch(type){
|
|
@@ -367,7 +364,7 @@ function createConsumerStream(from) {
|
|
|
367
364
|
const [_chunkId, status, data] = value;
|
|
368
365
|
switch(status){
|
|
369
366
|
case PROMISE_STATUS_FULFILLED:
|
|
370
|
-
resolve(hydrate(data));
|
|
367
|
+
resolve(hydrate(data, path));
|
|
371
368
|
break;
|
|
372
369
|
case PROMISE_STATUS_REJECTED:
|
|
373
370
|
reject(opts.formatError?.({
|
|
@@ -393,7 +390,7 @@ function createConsumerStream(from) {
|
|
|
393
390
|
throw value;
|
|
394
391
|
}
|
|
395
392
|
if (done) {
|
|
396
|
-
|
|
393
|
+
controllers.delete(chunkId);
|
|
397
394
|
return {
|
|
398
395
|
done: true,
|
|
399
396
|
value: undefined
|
|
@@ -404,26 +401,26 @@ function createConsumerStream(from) {
|
|
|
404
401
|
case ASYNC_ITERABLE_STATUS_VALUE:
|
|
405
402
|
return {
|
|
406
403
|
done: false,
|
|
407
|
-
value: hydrate(data)
|
|
404
|
+
value: hydrate(data, path)
|
|
408
405
|
};
|
|
409
406
|
case ASYNC_ITERABLE_STATUS_DONE:
|
|
410
|
-
|
|
407
|
+
controllers.delete(chunkId);
|
|
411
408
|
return {
|
|
412
409
|
done: true,
|
|
413
410
|
value: undefined
|
|
414
411
|
};
|
|
415
412
|
case ASYNC_ITERABLE_STATUS_ERROR:
|
|
416
|
-
|
|
413
|
+
controllers.delete(chunkId);
|
|
417
414
|
throw opts.formatError?.({
|
|
418
415
|
error: data
|
|
419
416
|
}) ?? new AsyncError(data);
|
|
420
417
|
}
|
|
421
418
|
},
|
|
422
419
|
return: async ()=>{
|
|
423
|
-
|
|
424
|
-
if (
|
|
425
|
-
// nothing
|
|
426
|
-
|
|
420
|
+
wrapper.abortController.abort();
|
|
421
|
+
if (chunkDeferred.size === 0 && Array.from(controllers.values()).every((it)=>it.abortController.signal.aborted)) {
|
|
422
|
+
// nothing is listening to the stream anymore
|
|
423
|
+
streamAbortController.abort();
|
|
427
424
|
}
|
|
428
425
|
return {
|
|
429
426
|
done: true,
|
|
@@ -437,15 +434,18 @@ function createConsumerStream(from) {
|
|
|
437
434
|
}
|
|
438
435
|
}
|
|
439
436
|
}
|
|
440
|
-
function hydrate(value) {
|
|
437
|
+
function hydrate(value, path) {
|
|
441
438
|
const [[data], ...asyncProps] = value;
|
|
442
439
|
for (const value1 of asyncProps){
|
|
443
|
-
const
|
|
444
|
-
const
|
|
445
|
-
|
|
440
|
+
const [key] = value1;
|
|
441
|
+
const hydrated = hydrateChunkDefinition(value1, key === null ? path : [
|
|
442
|
+
...path,
|
|
443
|
+
key
|
|
444
|
+
]);
|
|
445
|
+
if (key === null) {
|
|
446
446
|
return hydrated;
|
|
447
447
|
}
|
|
448
|
-
data[
|
|
448
|
+
data[key] = hydrated;
|
|
449
449
|
}
|
|
450
450
|
return data;
|
|
451
451
|
}
|
|
@@ -456,7 +456,7 @@ function createConsumerStream(from) {
|
|
|
456
456
|
deferred.reject(error);
|
|
457
457
|
}
|
|
458
458
|
chunkDeferred.clear();
|
|
459
|
-
for (const controller of controllers.values()){
|
|
459
|
+
for (const { controller } of controllers.values()){
|
|
460
460
|
controller.enqueue(error);
|
|
461
461
|
controller.close();
|
|
462
462
|
}
|
|
@@ -464,15 +464,17 @@ function createConsumerStream(from) {
|
|
|
464
464
|
};
|
|
465
465
|
source.pipeTo(new WritableStream({
|
|
466
466
|
start (controller) {
|
|
467
|
-
|
|
468
|
-
controller.error(
|
|
467
|
+
streamAbortController.signal.addEventListener('abort', ()=>{
|
|
468
|
+
controller.error(streamAbortController.signal.reason);
|
|
469
469
|
});
|
|
470
470
|
},
|
|
471
471
|
async write (chunkOrHead) {
|
|
472
472
|
if (headDeferred) {
|
|
473
473
|
const head = chunkOrHead;
|
|
474
474
|
for (const [key, value] of Object.entries(chunkOrHead)){
|
|
475
|
-
const parsed = hydrate(value
|
|
475
|
+
const parsed = hydrate(value, [
|
|
476
|
+
key
|
|
477
|
+
]);
|
|
476
478
|
head[key] = parsed;
|
|
477
479
|
}
|
|
478
480
|
headDeferred.resolve(head);
|
|
@@ -481,16 +483,16 @@ function createConsumerStream(from) {
|
|
|
481
483
|
}
|
|
482
484
|
const chunk = chunkOrHead;
|
|
483
485
|
const [idx] = chunk;
|
|
484
|
-
let
|
|
485
|
-
if (!
|
|
486
|
+
let wrapper = controllers.get(idx);
|
|
487
|
+
if (!wrapper) {
|
|
486
488
|
let deferred = chunkDeferred.get(idx);
|
|
487
489
|
if (!deferred) {
|
|
488
490
|
deferred = createDeferred();
|
|
489
491
|
chunkDeferred.set(idx, deferred);
|
|
490
492
|
}
|
|
491
|
-
|
|
493
|
+
wrapper = await deferred.promise;
|
|
492
494
|
}
|
|
493
|
-
controller.enqueue(chunk);
|
|
495
|
+
wrapper.controller.enqueue(chunk);
|
|
494
496
|
},
|
|
495
497
|
close: closeOrAbort,
|
|
496
498
|
abort: closeOrAbort
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/server",
|
|
3
|
-
"version": "11.0.0-alpha-tmp-issues-5851-take-two.
|
|
3
|
+
"version": "11.0.0-alpha-tmp-issues-5851-take-two.451+27b7d9bc9",
|
|
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": "
|
|
152
|
+
"gitHead": "27b7d9bc9e6568fe608c8354a147274d0205c5bf"
|
|
153
153
|
}
|
|
@@ -94,18 +94,16 @@ export function isPromise(value: unknown): value is Promise<unknown> {
|
|
|
94
94
|
type Serialize = (value: any) => any;
|
|
95
95
|
type Deserialize = (value: any) => any;
|
|
96
96
|
|
|
97
|
+
type PathArray = readonly (string | number)[];
|
|
97
98
|
export type ProducerOnError = (opts: {
|
|
98
99
|
error: unknown;
|
|
99
|
-
path:
|
|
100
|
+
path: PathArray;
|
|
100
101
|
}) => void;
|
|
101
102
|
export interface ProducerOptions {
|
|
102
103
|
serialize?: Serialize;
|
|
103
104
|
data: Record<string, unknown> | unknown[];
|
|
104
105
|
onError?: ProducerOnError;
|
|
105
|
-
formatError?: (opts: {
|
|
106
|
-
error: unknown;
|
|
107
|
-
path: (string | number)[];
|
|
108
|
-
}) => unknown;
|
|
106
|
+
formatError?: (opts: { error: unknown; path: PathArray }) => unknown;
|
|
109
107
|
maxDepth?: number;
|
|
110
108
|
}
|
|
111
109
|
|
|
@@ -426,7 +424,7 @@ export async function jsonlStreamConsumer<THead>(opts: {
|
|
|
426
424
|
formatError?: (opts: { error: unknown }) => Error;
|
|
427
425
|
}) {
|
|
428
426
|
const { deserialize = (v) => v } = opts;
|
|
429
|
-
const
|
|
427
|
+
const streamAbortController = new AbortController();
|
|
430
428
|
|
|
431
429
|
let source = createConsumerStream<Head>(opts.from);
|
|
432
430
|
if (deserialize) {
|
|
@@ -442,27 +440,28 @@ export async function jsonlStreamConsumer<THead>(opts: {
|
|
|
442
440
|
|
|
443
441
|
type ControllerChunk = ChunkData | StreamInterruptedError;
|
|
444
442
|
type ChunkController = ReadableStreamDefaultController<ControllerChunk>;
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
const deleteController = (idx: ChunkIndex) => {
|
|
449
|
-
controllers.delete(idx);
|
|
450
|
-
if (controllers.size === 0 && chunkDeferred.size === 0) {
|
|
451
|
-
// nothing can be listening to the stream anymore
|
|
452
|
-
abortController.abort();
|
|
453
|
-
}
|
|
443
|
+
type ControllerWrapper = {
|
|
444
|
+
controller: ChunkController;
|
|
445
|
+
abortController: AbortController;
|
|
454
446
|
};
|
|
447
|
+
const chunkDeferred = new Map<ChunkIndex, Deferred<ControllerWrapper>>();
|
|
448
|
+
const controllers = new Map<ChunkIndex, ControllerWrapper>();
|
|
455
449
|
|
|
456
|
-
function hydrateChunkDefinition(value: ChunkDefinition) {
|
|
450
|
+
function hydrateChunkDefinition(value: ChunkDefinition, path: PathArray) {
|
|
457
451
|
const [_path, type, chunkId] = value;
|
|
458
452
|
|
|
459
453
|
const { readable, controller } = createReadableStream<ChunkData>();
|
|
460
|
-
|
|
454
|
+
|
|
455
|
+
const wrapper: ControllerWrapper = {
|
|
456
|
+
controller,
|
|
457
|
+
abortController: new AbortController(),
|
|
458
|
+
};
|
|
459
|
+
controllers.set(chunkId, wrapper);
|
|
461
460
|
|
|
462
461
|
// resolve chunk deferred if it exists
|
|
463
462
|
const deferred = chunkDeferred.get(chunkId);
|
|
464
463
|
if (deferred) {
|
|
465
|
-
deferred.resolve(
|
|
464
|
+
deferred.resolve(wrapper);
|
|
466
465
|
chunkDeferred.delete(chunkId);
|
|
467
466
|
}
|
|
468
467
|
|
|
@@ -486,7 +485,7 @@ export async function jsonlStreamConsumer<THead>(opts: {
|
|
|
486
485
|
const [_chunkId, status, data] = value as PromiseChunk;
|
|
487
486
|
switch (status) {
|
|
488
487
|
case PROMISE_STATUS_FULFILLED:
|
|
489
|
-
resolve(hydrate(data));
|
|
488
|
+
resolve(hydrate(data, path));
|
|
490
489
|
break;
|
|
491
490
|
case PROMISE_STATUS_REJECTED:
|
|
492
491
|
reject(
|
|
@@ -513,7 +512,7 @@ export async function jsonlStreamConsumer<THead>(opts: {
|
|
|
513
512
|
throw value;
|
|
514
513
|
}
|
|
515
514
|
if (done) {
|
|
516
|
-
|
|
515
|
+
controllers.delete(chunkId);
|
|
517
516
|
return {
|
|
518
517
|
done: true,
|
|
519
518
|
value: undefined,
|
|
@@ -526,16 +525,16 @@ export async function jsonlStreamConsumer<THead>(opts: {
|
|
|
526
525
|
case ASYNC_ITERABLE_STATUS_VALUE:
|
|
527
526
|
return {
|
|
528
527
|
done: false,
|
|
529
|
-
value: hydrate(data),
|
|
528
|
+
value: hydrate(data, path),
|
|
530
529
|
};
|
|
531
530
|
case ASYNC_ITERABLE_STATUS_DONE:
|
|
532
|
-
|
|
531
|
+
controllers.delete(chunkId);
|
|
533
532
|
return {
|
|
534
533
|
done: true,
|
|
535
534
|
value: undefined,
|
|
536
535
|
};
|
|
537
536
|
case ASYNC_ITERABLE_STATUS_ERROR:
|
|
538
|
-
|
|
537
|
+
controllers.delete(chunkId);
|
|
539
538
|
throw (
|
|
540
539
|
opts.formatError?.({ error: data }) ??
|
|
541
540
|
new AsyncError(data)
|
|
@@ -543,11 +542,15 @@ export async function jsonlStreamConsumer<THead>(opts: {
|
|
|
543
542
|
}
|
|
544
543
|
},
|
|
545
544
|
return: async () => {
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
545
|
+
wrapper.abortController.abort();
|
|
546
|
+
if (
|
|
547
|
+
chunkDeferred.size === 0 &&
|
|
548
|
+
Array.from(controllers.values()).every(
|
|
549
|
+
(it) => it.abortController.signal.aborted,
|
|
550
|
+
)
|
|
551
|
+
) {
|
|
552
|
+
// nothing is listening to the stream anymore
|
|
553
|
+
streamAbortController.abort();
|
|
551
554
|
}
|
|
552
555
|
return {
|
|
553
556
|
done: true,
|
|
@@ -562,18 +565,21 @@ export async function jsonlStreamConsumer<THead>(opts: {
|
|
|
562
565
|
}
|
|
563
566
|
}
|
|
564
567
|
|
|
565
|
-
function hydrate(value: DehydratedValue): unknown {
|
|
568
|
+
function hydrate(value: DehydratedValue, path: PathArray): unknown {
|
|
566
569
|
const [[data], ...asyncProps] = value;
|
|
567
570
|
|
|
568
571
|
for (const value of asyncProps) {
|
|
569
|
-
const
|
|
572
|
+
const [key] = value;
|
|
573
|
+
const hydrated = hydrateChunkDefinition(
|
|
574
|
+
value,
|
|
575
|
+
key === null ? path : [...path, key],
|
|
576
|
+
);
|
|
570
577
|
|
|
571
|
-
|
|
572
|
-
if (path === null) {
|
|
578
|
+
if (key === null) {
|
|
573
579
|
return hydrated;
|
|
574
580
|
}
|
|
575
581
|
|
|
576
|
-
(data as any)[
|
|
582
|
+
(data as any)[key] = hydrated;
|
|
577
583
|
}
|
|
578
584
|
return data;
|
|
579
585
|
}
|
|
@@ -586,7 +592,7 @@ export async function jsonlStreamConsumer<THead>(opts: {
|
|
|
586
592
|
deferred.reject(error);
|
|
587
593
|
}
|
|
588
594
|
chunkDeferred.clear();
|
|
589
|
-
for (const controller of controllers.values()) {
|
|
595
|
+
for (const { controller } of controllers.values()) {
|
|
590
596
|
controller.enqueue(error);
|
|
591
597
|
controller.close();
|
|
592
598
|
}
|
|
@@ -596,8 +602,8 @@ export async function jsonlStreamConsumer<THead>(opts: {
|
|
|
596
602
|
.pipeTo(
|
|
597
603
|
new WritableStream({
|
|
598
604
|
start(controller) {
|
|
599
|
-
|
|
600
|
-
controller.error(
|
|
605
|
+
streamAbortController.signal.addEventListener('abort', () => {
|
|
606
|
+
controller.error(streamAbortController.signal.reason);
|
|
601
607
|
});
|
|
602
608
|
},
|
|
603
609
|
async write(chunkOrHead) {
|
|
@@ -605,7 +611,7 @@ export async function jsonlStreamConsumer<THead>(opts: {
|
|
|
605
611
|
const head = chunkOrHead as Record<number | string, unknown>;
|
|
606
612
|
|
|
607
613
|
for (const [key, value] of Object.entries(chunkOrHead)) {
|
|
608
|
-
const parsed = hydrate(value as any);
|
|
614
|
+
const parsed = hydrate(value as any, [key]);
|
|
609
615
|
head[key] = parsed;
|
|
610
616
|
}
|
|
611
617
|
headDeferred.resolve(head as THead);
|
|
@@ -614,17 +620,17 @@ export async function jsonlStreamConsumer<THead>(opts: {
|
|
|
614
620
|
}
|
|
615
621
|
const chunk = chunkOrHead as ChunkData;
|
|
616
622
|
const [idx] = chunk;
|
|
617
|
-
let
|
|
618
|
-
if (!
|
|
623
|
+
let wrapper = controllers.get(idx);
|
|
624
|
+
if (!wrapper) {
|
|
619
625
|
let deferred = chunkDeferred.get(idx);
|
|
620
626
|
if (!deferred) {
|
|
621
|
-
deferred = createDeferred
|
|
627
|
+
deferred = createDeferred();
|
|
622
628
|
chunkDeferred.set(idx, deferred);
|
|
623
629
|
}
|
|
624
630
|
|
|
625
|
-
|
|
631
|
+
wrapper = await deferred.promise;
|
|
626
632
|
}
|
|
627
|
-
controller.enqueue(chunk);
|
|
633
|
+
wrapper.controller.enqueue(chunk);
|
|
628
634
|
},
|
|
629
635
|
close: closeOrAbort,
|
|
630
636
|
abort: closeOrAbort,
|