@trpc/server 11.0.0-alpha-tmp-issues-5851-take-two.492 → 11.0.0-alpha-tmp-issues-5851-take-two.495

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.
@@ -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,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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,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"}
@@ -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
- async function createCtxPromise(getConnectionParams) {
29
- try {
30
- return await createContext?.({
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
- } catch (cause) {
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
- const ctx = undefined;
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) {
@@ -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 { isAsyncIterable, run, isObject } from '../unstable-core-do-not-import/utils.mjs';
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
- async function createCtxPromise(getConnectionParams) {
27
- try {
28
- return await createContext?.({
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
- } catch (cause) {
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
- const ctx = undefined;
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": 131324,
3
- "bundleOrigSize": 180714,
4
- "bundleReduction": 27.33,
2
+ "bundleSize": 131370,
3
+ "bundleOrigSize": 180751,
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": 14376,
40
- "origSize": 13603,
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.95,
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.13,
130
+ "percent": 4.12,
131
131
  "reduction": 11.38
132
132
  },
133
133
  {
@@ -193,9 +193,9 @@
193
193
  "removedExports": [],
194
194
  "dependents": [
195
195
  "/src/unstable-core-do-not-import.ts",
196
- "/src/unstable-core-do-not-import/http/resolveResponse.ts",
197
196
  "/src/unstable-core-do-not-import/initTRPC.ts",
198
- "/src/unstable-core-do-not-import/router.ts"
197
+ "/src/unstable-core-do-not-import/router.ts",
198
+ "/src/unstable-core-do-not-import/http/resolveResponse.ts"
199
199
  ],
200
200
  "percent": 2.09,
201
201
  "reduction": 45.94
@@ -319,14 +319,14 @@
319
319
  "removedExports": [],
320
320
  "dependents": [
321
321
  "/src/unstable-core-do-not-import.ts",
322
+ "/src/unstable-core-do-not-import/stream/sse.ts",
323
+ "/src/unstable-core-do-not-import/middleware.ts",
324
+ "/src/unstable-core-do-not-import/router.ts",
322
325
  "/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
323
326
  "/src/unstable-core-do-not-import/http/resolveResponse.ts",
324
327
  "/src/unstable-core-do-not-import/http/contentType.ts",
325
- "/src/unstable-core-do-not-import/middleware.ts",
326
328
  "/src/unstable-core-do-not-import/procedureBuilder.ts",
327
- "/src/unstable-core-do-not-import/router.ts",
328
- "/src/unstable-core-do-not-import/stream/jsonl.ts",
329
- "/src/unstable-core-do-not-import/stream/sse.ts"
329
+ "/src/unstable-core-do-not-import/stream/jsonl.ts"
330
330
  ],
331
331
  "percent": 1.32,
332
332
  "reduction": 19.47
@@ -393,8 +393,8 @@
393
393
  "removedExports": [],
394
394
  "dependents": [
395
395
  "/src/unstable-core-do-not-import.ts",
396
- "/src/unstable-core-do-not-import/http/resolveResponse.ts",
397
- "/src/unstable-core-do-not-import/error/getErrorShape.ts"
396
+ "/src/unstable-core-do-not-import/error/getErrorShape.ts",
397
+ "/src/unstable-core-do-not-import/http/resolveResponse.ts"
398
398
  ],
399
399
  "percent": 0.98,
400
400
  "reduction": 18.7
@@ -415,18 +415,18 @@
415
415
  "removedExports": [],
416
416
  "dependents": [
417
417
  "/src/unstable-core-do-not-import.ts",
418
+ "/src/unstable-core-do-not-import/error/TRPCError.ts",
419
+ "/src/unstable-core-do-not-import/stream/sse.ts",
420
+ "/src/unstable-core-do-not-import/transformer.ts",
421
+ "/src/unstable-core-do-not-import/middleware.ts",
422
+ "/src/unstable-core-do-not-import/router.ts",
418
423
  "/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
419
424
  "/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
420
425
  "/src/unstable-core-do-not-import/http/resolveResponse.ts",
421
426
  "/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
422
- "/src/unstable-core-do-not-import/error/TRPCError.ts",
423
427
  "/src/unstable-core-do-not-import/http/contentType.ts",
424
- "/src/unstable-core-do-not-import/middleware.ts",
425
428
  "/src/unstable-core-do-not-import/procedureBuilder.ts",
426
- "/src/unstable-core-do-not-import/router.ts",
427
- "/src/unstable-core-do-not-import/stream/jsonl.ts",
428
- "/src/unstable-core-do-not-import/stream/sse.ts",
429
- "/src/unstable-core-do-not-import/transformer.ts"
429
+ "/src/unstable-core-do-not-import/stream/jsonl.ts"
430
430
  ],
431
431
  "percent": 0.91,
432
432
  "reduction": 28.12
@@ -519,8 +519,8 @@
519
519
  "removedExports": [],
520
520
  "dependents": [
521
521
  "/src/unstable-core-do-not-import.ts",
522
- "/src/unstable-core-do-not-import/stream/jsonl.ts",
523
522
  "/src/unstable-core-do-not-import/stream/sse.ts",
523
+ "/src/unstable-core-do-not-import/stream/jsonl.ts",
524
524
  "/src/unstable-core-do-not-import/stream/utils/createReadableStream.ts"
525
525
  ],
526
526
  "percent": 0.75,
@@ -576,8 +576,8 @@
576
576
  ],
577
577
  "removedExports": [],
578
578
  "dependents": [
579
- "/src/unstable-core-do-not-import/stream/jsonl.ts",
580
- "/src/unstable-core-do-not-import/stream/sse.ts"
579
+ "/src/unstable-core-do-not-import/stream/sse.ts",
580
+ "/src/unstable-core-do-not-import/stream/jsonl.ts"
581
581
  ],
582
582
  "percent": 0.44,
583
583
  "reduction": 17.15
@@ -709,6 +709,16 @@
709
709
  "percent": 0.05,
710
710
  "reduction": 93.8
711
711
  },
712
+ {
713
+ "id": "/src/index.ts",
714
+ "size": 0,
715
+ "origSize": 32,
716
+ "renderedExports": [],
717
+ "removedExports": [],
718
+ "dependents": [],
719
+ "percent": 0,
720
+ "reduction": 100
721
+ },
712
722
  {
713
723
  "id": "/src/http.ts",
714
724
  "size": 0,
@@ -744,16 +754,6 @@
744
754
  "percent": 0,
745
755
  "reduction": 100
746
756
  },
747
- {
748
- "id": "/src/index.ts",
749
- "size": 0,
750
- "origSize": 32,
751
- "renderedExports": [],
752
- "removedExports": [],
753
- "dependents": [],
754
- "percent": 0,
755
- "reduction": 100
756
- },
757
757
  {
758
758
  "id": "/src/shared.ts",
759
759
  "size": 0,
@@ -796,16 +796,6 @@
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
- },
809
799
  {
810
800
  "id": "/src/adapters/node-http/index.ts",
811
801
  "size": 0,
@@ -814,12 +804,22 @@
814
804
  "removedExports": [],
815
805
  "dependents": [
816
806
  "/src/adapters/express.ts",
817
- "/src/adapters/next.ts",
818
807
  "/src/adapters/standalone.ts",
808
+ "/src/adapters/next.ts",
819
809
  "/src/adapters/fastify/fastifyRequestHandler.ts"
820
810
  ],
821
811
  "percent": 0,
822
812
  "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
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.492+b2b25b51d",
3
+ "version": "11.0.0-alpha-tmp-issues-5851-take-two.495+b70195a19",
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": "b2b25b51dd479e8c97e867da2d83735987ffc728"
152
+ "gitHead": "b70195a198a137a0252a4333f1880c7d3b373f43"
153
153
  }
@@ -107,11 +107,11 @@ export function getWSConnectionHandler<TRouter extends AnyRouter>(
107
107
  );
108
108
  }
109
109
 
110
- async function createCtxPromise(
110
+ function createCtxPromise(
111
111
  getConnectionParams: () => TRPCRequestInfo['connectionParams'],
112
112
  ): Promise<inferRouterContext<TRouter>> {
113
- try {
114
- return await createContext?.({
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
- } catch (cause) {
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
- const ctx: inferRouterContext<TRouter> | undefined = undefined;
170
+ let ctx: inferRouterContext<TRouter> | undefined = undefined;
169
171
 
170
172
  async function handleRequest(msg: TRPCClientOutgoingMessage) {
171
173
  const { id, jsonrpc } = msg;