@trpc/server 11.0.0-alpha-tmp-issues-5851-take-two.493 → 11.0.0-alpha-tmp-issues-5851-take-two.496
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/adapters/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +7 -6
- package/dist/adapters/ws.mjs +8 -7
- package/dist/bundle-analysis.json +32 -32
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +1 -1
- package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/adapters/ws.ts +8 -6
- package/src/unstable-core-do-not-import/rootConfig.ts +1 -1
|
@@ -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;AAatE,OAAO,EAIL,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,EAAE,CAAC,SAAS,CACb,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,CAAC,OAAO,SAAS,SAAS,IAAI,CAC1D,IAAI,EAAE,yBAAyB,KAC5B,YAAY,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;AAE/C,MAAM,MAAM,0BAA0B,CAAC,OAAO,SAAS,SAAS,IAC9D,kBAAkB,CAAC,OAAO,EAAE,eAAe,CAAC,GAC1C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AAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;AAE/C,MAAM,MAAM,0BAA0B,CAAC,OAAO,SAAS,SAAS,IAC9D,kBAAkB,CAAC,OAAO,EAAE,eAAe,CAAC,GAC1C,qBAAqB,CACnB,kBAAkB,CAAC,OAAO,CAAC,EAC3B,kBAAkB,CAAC,OAAO,CAAC,CAC5B,CAAC;AAEN;;GAEG;AACH,MAAM,MAAM,iBAAiB,CAAC,OAAO,SAAS,SAAS,IACrD,0BAA0B,CAAC,OAAO,CAAC,GAAG;IACpC,GAAG,EAAE,EAAE,CAAC,eAAe,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE;QACV;;;WAGG;QACH,OAAO,EAAE,OAAO,CAAC;QACjB;;;WAGG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB;;;WAGG;QACH,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH,CAAC;AAGJ,wBAAgB,sBAAsB,CAAC,OAAO,SAAS,SAAS,EAC9D,IAAI,EAAE,0BAA0B,CAAC,OAAO,CAAC,YAKnB,EAAE,CAAC,SAAS,OAAO,eAAe,mBAqUzD;AAiCD,wBAAgB,eAAe,CAAC,OAAO,SAAS,SAAS,EACvD,IAAI,EAAE,iBAAiB,CAAC,OAAO,CAAC;;EA+BjC"}
|
package/dist/adapters/ws.js
CHANGED
|
@@ -25,9 +25,9 @@ function getWSConnectionHandler(opts) {
|
|
|
25
25
|
function respond(untransformedJSON) {
|
|
26
26
|
client.send(JSON.stringify(transformer.transformTRPCResponse(router$1._def._config, untransformedJSON)));
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
function createCtxPromise(getConnectionParams) {
|
|
29
|
+
return utils.run(async ()=>{
|
|
30
|
+
ctx = await createContext?.({
|
|
31
31
|
req,
|
|
32
32
|
res: client,
|
|
33
33
|
info: {
|
|
@@ -39,7 +39,8 @@ function getWSConnectionHandler(opts) {
|
|
|
39
39
|
signal: abortController.signal
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
-
|
|
42
|
+
return ctx;
|
|
43
|
+
}).catch((cause)=>{
|
|
43
44
|
const error = TRPCError.getTRPCErrorFromUnknown(cause);
|
|
44
45
|
opts.onError?.({
|
|
45
46
|
error,
|
|
@@ -65,7 +66,7 @@ function getWSConnectionHandler(opts) {
|
|
|
65
66
|
client.close();
|
|
66
67
|
});
|
|
67
68
|
throw error;
|
|
68
|
-
}
|
|
69
|
+
});
|
|
69
70
|
}
|
|
70
71
|
/**
|
|
71
72
|
* promise for initializing the context
|
|
@@ -73,7 +74,7 @@ function getWSConnectionHandler(opts) {
|
|
|
73
74
|
* - the context promise will be created immediately on connection if no connectionParams are expected
|
|
74
75
|
* - if connection params are expected, they will be created once received
|
|
75
76
|
*/ let ctxPromise = toURL.toURL(req.url ?? '').searchParams.get('connectionParams') === '1' ? unsetContextSymbol : createCtxPromise(()=>null);
|
|
76
|
-
|
|
77
|
+
let ctx = undefined;
|
|
77
78
|
async function handleRequest(msg) {
|
|
78
79
|
const { id , jsonrpc } = msg;
|
|
79
80
|
/* istanbul ignore next -- @preserve */ if (id === null) {
|
package/dist/adapters/ws.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getErrorShape } from '../unstable-core-do-not-import/error/getErrorShape.mjs';
|
|
2
2
|
import { TRPCError, getTRPCErrorFromUnknown } from '../unstable-core-do-not-import/error/TRPCError.mjs';
|
|
3
|
-
import {
|
|
3
|
+
import { run, isAsyncIterable, isObject } from '../unstable-core-do-not-import/utils.mjs';
|
|
4
4
|
import { parseConnectionParamsFromUnknown } from '../unstable-core-do-not-import/http/parseConnectionParams.mjs';
|
|
5
5
|
import { parseTRPCMessage } from '../unstable-core-do-not-import/rpc/parseTRPCMessage.mjs';
|
|
6
6
|
import { isObservable, observableToAsyncIterable } from '../observable/observable.mjs';
|
|
@@ -23,9 +23,9 @@ function getWSConnectionHandler(opts) {
|
|
|
23
23
|
function respond(untransformedJSON) {
|
|
24
24
|
client.send(JSON.stringify(transformTRPCResponse(router._def._config, untransformedJSON)));
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
function createCtxPromise(getConnectionParams) {
|
|
27
|
+
return run(async ()=>{
|
|
28
|
+
ctx = await createContext?.({
|
|
29
29
|
req,
|
|
30
30
|
res: client,
|
|
31
31
|
info: {
|
|
@@ -37,7 +37,8 @@ function getWSConnectionHandler(opts) {
|
|
|
37
37
|
signal: abortController.signal
|
|
38
38
|
}
|
|
39
39
|
});
|
|
40
|
-
|
|
40
|
+
return ctx;
|
|
41
|
+
}).catch((cause)=>{
|
|
41
42
|
const error = getTRPCErrorFromUnknown(cause);
|
|
42
43
|
opts.onError?.({
|
|
43
44
|
error,
|
|
@@ -63,7 +64,7 @@ function getWSConnectionHandler(opts) {
|
|
|
63
64
|
client.close();
|
|
64
65
|
});
|
|
65
66
|
throw error;
|
|
66
|
-
}
|
|
67
|
+
});
|
|
67
68
|
}
|
|
68
69
|
/**
|
|
69
70
|
* promise for initializing the context
|
|
@@ -71,7 +72,7 @@ function getWSConnectionHandler(opts) {
|
|
|
71
72
|
* - the context promise will be created immediately on connection if no connectionParams are expected
|
|
72
73
|
* - if connection params are expected, they will be created once received
|
|
73
74
|
*/ let ctxPromise = toURL(req.url ?? '').searchParams.get('connectionParams') === '1' ? unsetContextSymbol : createCtxPromise(()=>null);
|
|
74
|
-
|
|
75
|
+
let ctx = undefined;
|
|
75
76
|
async function handleRequest(msg) {
|
|
76
77
|
const { id , jsonrpc } = msg;
|
|
77
78
|
/* istanbul ignore next -- @preserve */ if (id === null) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction": 27.
|
|
2
|
+
"bundleSize": 131370,
|
|
3
|
+
"bundleOrigSize": 180752,
|
|
4
|
+
"bundleReduction": 27.32,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/unstable-core-do-not-import/stream/jsonl.ts",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
"id": "/src/adapters/ws.ts",
|
|
39
|
-
"size":
|
|
40
|
-
"origSize":
|
|
39
|
+
"size": 14422,
|
|
40
|
+
"origSize": 13640,
|
|
41
41
|
"renderedExports": [
|
|
42
42
|
"getWSConnectionHandler",
|
|
43
43
|
"applyWSSHandler"
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"dependents": [
|
|
47
47
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
48
48
|
],
|
|
49
|
-
"percent": 10.
|
|
49
|
+
"percent": 10.98,
|
|
50
50
|
"reduction": 0
|
|
51
51
|
},
|
|
52
52
|
{
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
"dependents": [
|
|
128
128
|
"/src/adapters/aws-lambda/index.ts"
|
|
129
129
|
],
|
|
130
|
-
"percent": 4.
|
|
130
|
+
"percent": 4.12,
|
|
131
131
|
"reduction": 11.38
|
|
132
132
|
},
|
|
133
133
|
{
|
|
@@ -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",
|
|
421
422
|
"/src/unstable-core-do-not-import/error/TRPCError.ts",
|
|
422
423
|
"/src/unstable-core-do-not-import/stream/sse.ts",
|
|
423
424
|
"/src/unstable-core-do-not-import/transformer.ts",
|
|
424
425
|
"/src/unstable-core-do-not-import/middleware.ts",
|
|
425
426
|
"/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"
|
|
@@ -598,7 +598,7 @@
|
|
|
598
598
|
{
|
|
599
599
|
"id": "/src/unstable-core-do-not-import/rootConfig.ts",
|
|
600
600
|
"size": 343,
|
|
601
|
-
"origSize":
|
|
601
|
+
"origSize": 3235,
|
|
602
602
|
"renderedExports": [
|
|
603
603
|
"isServerDefault"
|
|
604
604
|
],
|
|
@@ -608,7 +608,7 @@
|
|
|
608
608
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
609
609
|
],
|
|
610
610
|
"percent": 0.26,
|
|
611
|
-
"reduction": 89.
|
|
611
|
+
"reduction": 89.4
|
|
612
612
|
},
|
|
613
613
|
{
|
|
614
614
|
"id": "/src/adapters/express.ts",
|
|
@@ -721,6 +721,16 @@
|
|
|
721
721
|
"percent": 0,
|
|
722
722
|
"reduction": 100
|
|
723
723
|
},
|
|
724
|
+
{
|
|
725
|
+
"id": "/src/rpc.ts",
|
|
726
|
+
"size": 0,
|
|
727
|
+
"origSize": 36,
|
|
728
|
+
"renderedExports": [],
|
|
729
|
+
"removedExports": [],
|
|
730
|
+
"dependents": [],
|
|
731
|
+
"percent": 0,
|
|
732
|
+
"reduction": 100
|
|
733
|
+
},
|
|
724
734
|
{
|
|
725
735
|
"id": "/src/index.ts",
|
|
726
736
|
"size": 0,
|
|
@@ -732,9 +742,9 @@
|
|
|
732
742
|
"reduction": 100
|
|
733
743
|
},
|
|
734
744
|
{
|
|
735
|
-
"id": "/src/
|
|
745
|
+
"id": "/src/shared.ts",
|
|
736
746
|
"size": 0,
|
|
737
|
-
"origSize":
|
|
747
|
+
"origSize": 653,
|
|
738
748
|
"renderedExports": [],
|
|
739
749
|
"removedExports": [],
|
|
740
750
|
"dependents": [],
|
|
@@ -754,16 +764,6 @@
|
|
|
754
764
|
"percent": 0,
|
|
755
765
|
"reduction": 100
|
|
756
766
|
},
|
|
757
|
-
{
|
|
758
|
-
"id": "/src/shared.ts",
|
|
759
|
-
"size": 0,
|
|
760
|
-
"origSize": 653,
|
|
761
|
-
"renderedExports": [],
|
|
762
|
-
"removedExports": [],
|
|
763
|
-
"dependents": [],
|
|
764
|
-
"percent": 0,
|
|
765
|
-
"reduction": 100
|
|
766
|
-
},
|
|
767
767
|
{
|
|
768
768
|
"id": "/src/adapters/next-app-dir.ts",
|
|
769
769
|
"size": 0,
|
|
@@ -796,6 +796,16 @@
|
|
|
796
796
|
"percent": 0,
|
|
797
797
|
"reduction": 100
|
|
798
798
|
},
|
|
799
|
+
{
|
|
800
|
+
"id": "/src/adapters/fetch/index.ts",
|
|
801
|
+
"size": 0,
|
|
802
|
+
"origSize": 64,
|
|
803
|
+
"renderedExports": [],
|
|
804
|
+
"removedExports": [],
|
|
805
|
+
"dependents": [],
|
|
806
|
+
"percent": 0,
|
|
807
|
+
"reduction": 100
|
|
808
|
+
},
|
|
799
809
|
{
|
|
800
810
|
"id": "/src/adapters/node-http/index.ts",
|
|
801
811
|
"size": 0,
|
|
@@ -810,16 +820,6 @@
|
|
|
810
820
|
],
|
|
811
821
|
"percent": 0,
|
|
812
822
|
"reduction": 100
|
|
813
|
-
},
|
|
814
|
-
{
|
|
815
|
-
"id": "/src/adapters/fetch/index.ts",
|
|
816
|
-
"size": 0,
|
|
817
|
-
"origSize": 64,
|
|
818
|
-
"renderedExports": [],
|
|
819
|
-
"removedExports": [],
|
|
820
|
-
"dependents": [],
|
|
821
|
-
"percent": 0,
|
|
822
|
-
"reduction": 100
|
|
823
823
|
}
|
|
824
824
|
],
|
|
825
825
|
"moduleCount": 55
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rootConfig.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/rootConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,g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E,GAAG,CAAC;IACV,UAAU,EAAE,GAAG,CAAC;IAChB,WAAW,EAAE,GAAG,CAAC;CAClB,CAAC,CAAC;AAEH,KAAK,SAAS,CAAC,UAAU,SAAS,OAAO,EAAE,KAAK,IAAI,UAAU,SAAS,IAAI,GACvE,OAAO,CAAC,KAAK,CAAC,GACd,KAAK,CAAC;AAEV;;;GAGG;AACH,MAAM,MAAM,qBAAqB,CAC/B,QAAQ,EACR,SAAS,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,IACvC,SAAS,CACX,MAAM,SAAS,QAAQ,GAAG,IAAI,GAAG,KAAK,EACtC;IACE;;QAEI;IACJ,aAAa,EAAE,SAAS,CAAC;CAC1B,CACF,CAAC"}
|
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.496+f0729daa3",
|
|
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": "f0729daa3e95b1f21cd082e04c21377b550f5625"
|
|
153
153
|
}
|
package/src/adapters/ws.ts
CHANGED
|
@@ -107,11 +107,11 @@ export function getWSConnectionHandler<TRouter extends AnyRouter>(
|
|
|
107
107
|
);
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
function createCtxPromise(
|
|
111
111
|
getConnectionParams: () => TRPCRequestInfo['connectionParams'],
|
|
112
112
|
): Promise<inferRouterContext<TRouter>> {
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
return run(async () => {
|
|
114
|
+
ctx = await createContext?.({
|
|
115
115
|
req,
|
|
116
116
|
res: client,
|
|
117
117
|
info: {
|
|
@@ -123,7 +123,9 @@ export function getWSConnectionHandler<TRouter extends AnyRouter>(
|
|
|
123
123
|
signal: abortController.signal,
|
|
124
124
|
},
|
|
125
125
|
});
|
|
126
|
-
|
|
126
|
+
|
|
127
|
+
return ctx;
|
|
128
|
+
}).catch((cause) => {
|
|
127
129
|
const error = getTRPCErrorFromUnknown(cause);
|
|
128
130
|
opts.onError?.({
|
|
129
131
|
error,
|
|
@@ -151,7 +153,7 @@ export function getWSConnectionHandler<TRouter extends AnyRouter>(
|
|
|
151
153
|
});
|
|
152
154
|
|
|
153
155
|
throw error;
|
|
154
|
-
}
|
|
156
|
+
});
|
|
155
157
|
}
|
|
156
158
|
|
|
157
159
|
/**
|
|
@@ -165,7 +167,7 @@ export function getWSConnectionHandler<TRouter extends AnyRouter>(
|
|
|
165
167
|
? unsetContextSymbol
|
|
166
168
|
: createCtxPromise(() => null);
|
|
167
169
|
|
|
168
|
-
|
|
170
|
+
let ctx: inferRouterContext<TRouter> | undefined = undefined;
|
|
169
171
|
|
|
170
172
|
async function handleRequest(msg: TRPCClientOutgoingMessage) {
|
|
171
173
|
const { id, jsonrpc } = msg;
|