@trpc/server 11.0.0-rc.456 → 11.0.0-rc.458

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.
@@ -15,7 +15,7 @@ var router = require('../unstable-core-do-not-import/router.js');
15
15
  * Importing ws causes a build error
16
16
  * @link https://github.com/trpc/trpc/pull/5279
17
17
  */ const WEBSOCKET_OPEN = 1; /* ws.WebSocket.OPEN */
18
- const unsetContextSymbol = Symbol('unsetContext');
18
+ const unsetContextPromiseSymbol = Symbol('unsetContextPromise');
19
19
  function getWSConnectionHandler(opts) {
20
20
  const { createContext , router: router$1 } = opts;
21
21
  const { transformer: transformer$1 } = router$1._def._config;
@@ -68,13 +68,13 @@ function getWSConnectionHandler(opts) {
68
68
  throw error;
69
69
  });
70
70
  }
71
+ let ctx = undefined;
71
72
  /**
72
73
  * promise for initializing the context
73
74
  *
74
75
  * - the context promise will be created immediately on connection if no connectionParams are expected
75
76
  * - if connection params are expected, they will be created once received
76
- */ let ctxPromise = toURL.toURL(req.url ?? '').searchParams.get('connectionParams') === '1' ? unsetContextSymbol : createCtxPromise(()=>null);
77
- let ctx = undefined;
77
+ */ let ctxPromise = toURL.toURL(req.url ?? '').searchParams.get('connectionParams') === '1' ? unsetContextPromiseSymbol : createCtxPromise(()=>null);
78
78
  async function handleRequest(msg) {
79
79
  const { id , jsonrpc } = msg;
80
80
  /* istanbul ignore next -- @preserve */ if (id === null) {
@@ -247,7 +247,7 @@ function getWSConnectionHandler(opts) {
247
247
  }
248
248
  }
249
249
  client.on('message', async (message)=>{
250
- if (ctxPromise === unsetContextSymbol) {
250
+ if (ctxPromise === unsetContextPromiseSymbol) {
251
251
  // If the ctxPromise wasn't created immediately, we're expecting the first message to be a TRPCConnectionParamsMessage
252
252
  ctxPromise = createCtxPromise(()=>{
253
253
  let msg;
@@ -314,7 +314,7 @@ function getWSConnectionHandler(opts) {
314
314
  clientSubscriptions.clear();
315
315
  abortController.abort();
316
316
  });
317
- if (ctxPromise !== unsetContextSymbol) {
317
+ if (ctxPromise !== unsetContextPromiseSymbol) {
318
318
  // prevent unhandled promise rejection errors
319
319
  await ctxPromise.catch(()=>null);
320
320
  }
@@ -13,7 +13,7 @@ import { callProcedure } from '../unstable-core-do-not-import/router.mjs';
13
13
  * Importing ws causes a build error
14
14
  * @link https://github.com/trpc/trpc/pull/5279
15
15
  */ const WEBSOCKET_OPEN = 1; /* ws.WebSocket.OPEN */
16
- const unsetContextSymbol = Symbol('unsetContext');
16
+ const unsetContextPromiseSymbol = Symbol('unsetContextPromise');
17
17
  function getWSConnectionHandler(opts) {
18
18
  const { createContext , router } = opts;
19
19
  const { transformer } = router._def._config;
@@ -66,13 +66,13 @@ function getWSConnectionHandler(opts) {
66
66
  throw error;
67
67
  });
68
68
  }
69
+ let ctx = undefined;
69
70
  /**
70
71
  * promise for initializing the context
71
72
  *
72
73
  * - the context promise will be created immediately on connection if no connectionParams are expected
73
74
  * - if connection params are expected, they will be created once received
74
- */ let ctxPromise = toURL(req.url ?? '').searchParams.get('connectionParams') === '1' ? unsetContextSymbol : createCtxPromise(()=>null);
75
- let ctx = undefined;
75
+ */ let ctxPromise = toURL(req.url ?? '').searchParams.get('connectionParams') === '1' ? unsetContextPromiseSymbol : createCtxPromise(()=>null);
76
76
  async function handleRequest(msg) {
77
77
  const { id , jsonrpc } = msg;
78
78
  /* istanbul ignore next -- @preserve */ if (id === null) {
@@ -245,7 +245,7 @@ function getWSConnectionHandler(opts) {
245
245
  }
246
246
  }
247
247
  client.on('message', async (message)=>{
248
- if (ctxPromise === unsetContextSymbol) {
248
+ if (ctxPromise === unsetContextPromiseSymbol) {
249
249
  // If the ctxPromise wasn't created immediately, we're expecting the first message to be a TRPCConnectionParamsMessage
250
250
  ctxPromise = createCtxPromise(()=>{
251
251
  let msg;
@@ -312,7 +312,7 @@ function getWSConnectionHandler(opts) {
312
312
  clientSubscriptions.clear();
313
313
  abortController.abort();
314
314
  });
315
- if (ctxPromise !== unsetContextSymbol) {
315
+ if (ctxPromise !== unsetContextPromiseSymbol) {
316
316
  // prevent unhandled promise rejection errors
317
317
  await ctxPromise.catch(()=>null);
318
318
  }
@@ -1,7 +1,7 @@
1
1
  {
2
- "bundleSize": 131618,
3
- "bundleOrigSize": 181007,
4
- "bundleReduction": 27.29,
2
+ "bundleSize": 131653,
3
+ "bundleOrigSize": 181042,
4
+ "bundleReduction": 27.28,
5
5
  "modules": [
6
6
  {
7
7
  "id": "/src/unstable-core-do-not-import/stream/jsonl.ts",
@@ -31,13 +31,13 @@
31
31
  "dependents": [
32
32
  "/src/unstable-core-do-not-import.ts"
33
33
  ],
34
- "percent": 13.04,
34
+ "percent": 13.03,
35
35
  "reduction": 0
36
36
  },
37
37
  {
38
38
  "id": "/src/adapters/ws.ts",
39
- "size": 14422,
40
- "origSize": 13640,
39
+ "size": 14457,
40
+ "origSize": 13675,
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.96,
49
+ "percent": 10.98,
50
50
  "reduction": 0
51
51
  },
52
52
  {
@@ -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"
@@ -592,7 +592,7 @@
592
592
  ],
593
593
  "removedExports": [],
594
594
  "dependents": [],
595
- "percent": 0.4,
595
+ "percent": 0.39,
596
596
  "reduction": 67.09
597
597
  },
598
598
  {
@@ -722,9 +722,9 @@
722
722
  "reduction": 100
723
723
  },
724
724
  {
725
- "id": "/src/rpc.ts",
725
+ "id": "/src/index.ts",
726
726
  "size": 0,
727
- "origSize": 36,
727
+ "origSize": 32,
728
728
  "renderedExports": [],
729
729
  "removedExports": [],
730
730
  "dependents": [],
@@ -742,9 +742,9 @@
742
742
  "reduction": 100
743
743
  },
744
744
  {
745
- "id": "/src/index.ts",
745
+ "id": "/src/rpc.ts",
746
746
  "size": 0,
747
- "origSize": 32,
747
+ "origSize": 36,
748
748
  "renderedExports": [],
749
749
  "removedExports": [],
750
750
  "dependents": [],
@@ -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/standalone.ts",
818
807
  "/src/adapters/next.ts",
808
+ "/src/adapters/standalone.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-rc.456+a9a2c25b1",
3
+ "version": "11.0.0-rc.458+46c7eea82",
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": "a9a2c25b1ead6113bde45bb26c627e3696fb61a8"
152
+ "gitHead": "46c7eea8285542a1115c9dada7b45e9b07f7c23d"
153
153
  }
@@ -88,7 +88,7 @@ export type WSSHandlerOptions<TRouter extends AnyRouter> =
88
88
  };
89
89
  };
90
90
 
91
- const unsetContextSymbol = Symbol('unsetContext');
91
+ const unsetContextPromiseSymbol = Symbol('unsetContextPromise');
92
92
  export function getWSConnectionHandler<TRouter extends AnyRouter>(
93
93
  opts: WSConnectionHandlerOptions<TRouter>,
94
94
  ) {
@@ -156,6 +156,8 @@ export function getWSConnectionHandler<TRouter extends AnyRouter>(
156
156
  });
157
157
  }
158
158
 
159
+ let ctx: inferRouterContext<TRouter> | undefined = undefined;
160
+
159
161
  /**
160
162
  * promise for initializing the context
161
163
  *
@@ -164,11 +166,9 @@ export function getWSConnectionHandler<TRouter extends AnyRouter>(
164
166
  */
165
167
  let ctxPromise =
166
168
  toURL(req.url ?? '').searchParams.get('connectionParams') === '1'
167
- ? unsetContextSymbol
169
+ ? unsetContextPromiseSymbol
168
170
  : createCtxPromise(() => null);
169
171
 
170
- let ctx: inferRouterContext<TRouter> | undefined = undefined;
171
-
172
172
  async function handleRequest(msg: TRPCClientOutgoingMessage) {
173
173
  const { id, jsonrpc } = msg;
174
174
  /* istanbul ignore next -- @preserve */
@@ -341,7 +341,7 @@ export function getWSConnectionHandler<TRouter extends AnyRouter>(
341
341
  }
342
342
  }
343
343
  client.on('message', async (message) => {
344
- if (ctxPromise === unsetContextSymbol) {
344
+ if (ctxPromise === unsetContextPromiseSymbol) {
345
345
  // If the ctxPromise wasn't created immediately, we're expecting the first message to be a TRPCConnectionParamsMessage
346
346
  ctxPromise = createCtxPromise(() => {
347
347
  let msg;
@@ -415,7 +415,7 @@ export function getWSConnectionHandler<TRouter extends AnyRouter>(
415
415
  abortController.abort();
416
416
  });
417
417
 
418
- if (ctxPromise !== unsetContextSymbol) {
418
+ if (ctxPromise !== unsetContextPromiseSymbol) {
419
419
  // prevent unhandled promise rejection errors
420
420
  await ctxPromise.catch(() => null);
421
421
  }