@trpc/client 11.0.4-canary.1 → 11.0.5-canary.2

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,7 +1,7 @@
1
1
  {
2
- "bundleSize": 76026,
3
- "bundleOrigSize": 94417,
4
- "bundleReduction": 19.48,
2
+ "bundleSize": 76422,
3
+ "bundleOrigSize": 94937,
4
+ "bundleReduction": 19.5,
5
5
  "modules": [
6
6
  {
7
7
  "id": "/src/links/wsLink/wsClient/wsClient.ts",
@@ -14,7 +14,7 @@
14
14
  "dependents": [
15
15
  "/src/links/wsLink/createWsClient.ts"
16
16
  ],
17
- "percent": 15.87,
17
+ "percent": 15.79,
18
18
  "reduction": 1.08
19
19
  },
20
20
  {
@@ -27,7 +27,7 @@
27
27
  ],
28
28
  "removedExports": [],
29
29
  "dependents": [],
30
- "percent": 10.63,
30
+ "percent": 10.58,
31
31
  "reduction": 0
32
32
  },
33
33
  {
@@ -42,7 +42,7 @@
42
42
  "dependents": [
43
43
  "/src/links/wsLink/wsClient/wsClient.ts"
44
44
  ],
45
- "percent": 8.12,
45
+ "percent": 8.08,
46
46
  "reduction": 4.9
47
47
  },
48
48
  {
@@ -55,7 +55,7 @@
55
55
  ],
56
56
  "removedExports": [],
57
57
  "dependents": [],
58
- "percent": 8.06,
58
+ "percent": 8.02,
59
59
  "reduction": 0
60
60
  },
61
61
  {
@@ -67,7 +67,7 @@
67
67
  ],
68
68
  "removedExports": [],
69
69
  "dependents": [],
70
- "percent": 7.36,
70
+ "percent": 7.32,
71
71
  "reduction": 19.44
72
72
  },
73
73
  {
@@ -81,7 +81,7 @@
81
81
  "dependents": [
82
82
  "/src/links/wsLink/wsClient/wsClient.ts"
83
83
  ],
84
- "percent": 6.3,
84
+ "percent": 6.27,
85
85
  "reduction": 8.13
86
86
  },
87
87
  {
@@ -93,7 +93,7 @@
93
93
  ],
94
94
  "removedExports": [],
95
95
  "dependents": [],
96
- "percent": 5.42,
96
+ "percent": 5.4,
97
97
  "reduction": 4.6
98
98
  },
99
99
  {
@@ -108,7 +108,7 @@
108
108
  "/src/links/httpBatchLink.ts",
109
109
  "/src/links/httpBatchStreamLink.ts"
110
110
  ],
111
- "percent": 5.37,
111
+ "percent": 5.34,
112
112
  "reduction": 5.64
113
113
  },
114
114
  {
@@ -131,7 +131,7 @@
131
131
  "/src/links/httpBatchStreamLink.ts",
132
132
  "/src/links/httpSubscriptionLink.ts"
133
133
  ],
134
- "percent": 4.86,
134
+ "percent": 4.83,
135
135
  "reduction": 37.14
136
136
  },
137
137
  {
@@ -143,7 +143,7 @@
143
143
  ],
144
144
  "removedExports": [],
145
145
  "dependents": [],
146
- "percent": 4.33,
146
+ "percent": 4.31,
147
147
  "reduction": 12.56
148
148
  },
149
149
  {
@@ -158,7 +158,7 @@
158
158
  "/src/createTRPCUntypedClient.ts",
159
159
  "/src/createTRPCClient.ts"
160
160
  ],
161
- "percent": 4.15,
161
+ "percent": 4.13,
162
162
  "reduction": 28.5
163
163
  },
164
164
  {
@@ -178,7 +178,7 @@
178
178
  "/src/internals/TRPCUntypedClient.ts",
179
179
  "/src/links/wsLink/wsClient/wsClient.ts"
180
180
  ],
181
- "percent": 3.67,
181
+ "percent": 3.65,
182
182
  "reduction": 21.8
183
183
  },
184
184
  {
@@ -198,20 +198,20 @@
198
198
  "/src/links/wsLink/wsClient/requestManager.ts",
199
199
  "/src/links/wsLink/wsClient/wsConnection.ts"
200
200
  ],
201
- "percent": 3.66,
201
+ "percent": 3.64,
202
202
  "reduction": 0.47
203
203
  },
204
204
  {
205
205
  "id": "/src/links/retryLink.ts",
206
- "size": 2194,
207
- "origSize": 2702,
206
+ "size": 2590,
207
+ "origSize": 3222,
208
208
  "renderedExports": [
209
209
  "retryLink"
210
210
  ],
211
211
  "removedExports": [],
212
212
  "dependents": [],
213
- "percent": 2.89,
214
- "reduction": 18.8
213
+ "percent": 3.39,
214
+ "reduction": 19.62
215
215
  },
216
216
  {
217
217
  "id": "/src/internals/signals.ts",
@@ -227,7 +227,7 @@
227
227
  "/src/links/httpBatchStreamLink.ts",
228
228
  "/src/links/httpSubscriptionLink.ts"
229
229
  ],
230
- "percent": 1.56,
230
+ "percent": 1.55,
231
231
  "reduction": 3.88
232
232
  },
233
233
  {
@@ -244,7 +244,7 @@
244
244
  "dependents": [
245
245
  "/src/index.ts"
246
246
  ],
247
- "percent": 1.54,
247
+ "percent": 1.53,
248
248
  "reduction": 75.3
249
249
  },
250
250
  {
@@ -257,7 +257,7 @@
257
257
  ],
258
258
  "removedExports": [],
259
259
  "dependents": [],
260
- "percent": 1.24,
260
+ "percent": 1.23,
261
261
  "reduction": 41.31
262
262
  },
263
263
  {
@@ -272,7 +272,7 @@
272
272
  "/src/links/splitLink.ts",
273
273
  "/src/internals/TRPCUntypedClient.ts"
274
274
  ],
275
- "percent": 0.91,
275
+ "percent": 0.9,
276
276
  "reduction": 32.75
277
277
  },
278
278
  {
@@ -314,7 +314,7 @@
314
314
  "dependents": [
315
315
  "/src/links/wsLink/wsClient/wsClient.ts"
316
316
  ],
317
- "percent": 0.64,
317
+ "percent": 0.63,
318
318
  "reduction": 81.6
319
319
  },
320
320
  {
@@ -373,7 +373,7 @@
373
373
  "/src/links/httpSubscriptionLink.ts",
374
374
  "/src/links/wsLink/wsClient/utils.ts"
375
375
  ],
376
- "percent": 0.32,
376
+ "percent": 0.31,
377
377
  "reduction": 76.38
378
378
  },
379
379
  {
@@ -6,6 +6,10 @@ interface RetryLinkOptions<TInferrable extends InferrableClientTypes> {
6
6
  * The retry function
7
7
  */
8
8
  retry: (opts: RetryFnOptions<TInferrable>) => boolean;
9
+ /**
10
+ * The delay between retries in ms (defaults to 0)
11
+ */
12
+ retryDelayMs?: (attempt: number) => number;
9
13
  }
10
14
  interface RetryFnOptions<TInferrable extends InferrableClientTypes> {
11
15
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"retryLink.d.ts","sourceRoot":"","sources":["../../src/links/retryLink.ts"],"names":[],"mappings":"A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AAC;IACd;;OAEG;IACH,KAAK,EAAE,eAAe,CAAC,WAAW,CAAC,CAAC;IACpC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,WAAW,SAAS,qBAAqB,EACjE,IAAI,EAAE,gBAAgB,CAAC,WAAW,CAAC,GAClC,QAAQ,CAAC,WAAW,CAAC,CA4EvB"}
@@ -14,6 +14,7 @@ var inputWithTrackedEventId = require('../internals/inputWithTrackedEventId.js')
14
14
  // initialized for request
15
15
  return observable.observable((observer)=>{
16
16
  let next$;
17
+ let callNextTimeout = undefined;
17
18
  let lastEventId = undefined;
18
19
  attempt(1);
19
20
  function opWithLastEventId() {
@@ -35,11 +36,16 @@ var inputWithTrackedEventId = require('../internals/inputWithTrackedEventId.js')
35
36
  attempts,
36
37
  error
37
38
  });
38
- if (shouldRetry) {
39
- attempt(attempts + 1);
40
- } else {
39
+ if (!shouldRetry) {
41
40
  observer.error(error);
41
+ return;
42
+ }
43
+ const delayMs = opts.retryDelayMs?.(attempts) ?? 0;
44
+ if (delayMs <= 0) {
45
+ attempt(attempts + 1);
46
+ return;
42
47
  }
48
+ callNextTimeout = setTimeout(()=>attempt(attempts + 1), delayMs);
43
49
  },
44
50
  next (envelope) {
45
51
  //
@@ -56,6 +62,7 @@ var inputWithTrackedEventId = require('../internals/inputWithTrackedEventId.js')
56
62
  }
57
63
  return ()=>{
58
64
  next$.unsubscribe();
65
+ clearTimeout(callNextTimeout);
59
66
  };
60
67
  });
61
68
  };
@@ -12,6 +12,7 @@ import { inputWithTrackedEventId } from '../internals/inputWithTrackedEventId.mj
12
12
  // initialized for request
13
13
  return observable((observer)=>{
14
14
  let next$;
15
+ let callNextTimeout = undefined;
15
16
  let lastEventId = undefined;
16
17
  attempt(1);
17
18
  function opWithLastEventId() {
@@ -33,11 +34,16 @@ import { inputWithTrackedEventId } from '../internals/inputWithTrackedEventId.mj
33
34
  attempts,
34
35
  error
35
36
  });
36
- if (shouldRetry) {
37
- attempt(attempts + 1);
38
- } else {
37
+ if (!shouldRetry) {
39
38
  observer.error(error);
39
+ return;
40
+ }
41
+ const delayMs = opts.retryDelayMs?.(attempts) ?? 0;
42
+ if (delayMs <= 0) {
43
+ attempt(attempts + 1);
44
+ return;
40
45
  }
46
+ callNextTimeout = setTimeout(()=>attempt(attempts + 1), delayMs);
41
47
  },
42
48
  next (envelope) {
43
49
  //
@@ -54,6 +60,7 @@ import { inputWithTrackedEventId } from '../internals/inputWithTrackedEventId.mj
54
60
  }
55
61
  return ()=>{
56
62
  next$.unsubscribe();
63
+ clearTimeout(callNextTimeout);
57
64
  };
58
65
  });
59
66
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/client",
3
- "version": "11.0.4-canary.1+c5eb0b32c",
3
+ "version": "11.0.5-canary.2+129addc5f",
4
4
  "description": "The tRPC client library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -77,11 +77,11 @@
77
77
  "!**/__tests__"
78
78
  ],
79
79
  "peerDependencies": {
80
- "@trpc/server": "11.0.4-canary.1+c5eb0b32c",
80
+ "@trpc/server": "11.0.5-canary.2+129addc5f",
81
81
  "typescript": ">=5.7.2"
82
82
  },
83
83
  "devDependencies": {
84
- "@trpc/server": "11.0.4-canary.1+c5eb0b32c",
84
+ "@trpc/server": "11.0.5-canary.2+129addc5f",
85
85
  "@types/isomorphic-fetch": "^0.0.39",
86
86
  "@types/node": "^22.13.5",
87
87
  "dataloader": "^2.2.2",
@@ -101,5 +101,5 @@
101
101
  "funding": [
102
102
  "https://trpc.io/sponsor"
103
103
  ],
104
- "gitHead": "c5eb0b32c96834d58c650e29053de241536c5fa9"
104
+ "gitHead": "129addc5f2cd183d99c383e47cea4916d648d927"
105
105
  }
@@ -12,6 +12,10 @@ interface RetryLinkOptions<TInferrable extends InferrableClientTypes> {
12
12
  * The retry function
13
13
  */
14
14
  retry: (opts: RetryFnOptions<TInferrable>) => boolean;
15
+ /**
16
+ * The delay between retries in ms (defaults to 0)
17
+ */
18
+ retryDelayMs?: (attempt: number) => number;
15
19
  }
16
20
 
17
21
  interface RetryFnOptions<TInferrable extends InferrableClientTypes> {
@@ -42,6 +46,8 @@ export function retryLink<TInferrable extends InferrableClientTypes>(
42
46
  // initialized for request
43
47
  return observable((observer) => {
44
48
  let next$: Unsubscribable;
49
+ let callNextTimeout: ReturnType<typeof setTimeout> | undefined =
50
+ undefined;
45
51
 
46
52
  let lastEventId: string | undefined = undefined;
47
53
 
@@ -69,11 +75,20 @@ export function retryLink<TInferrable extends InferrableClientTypes>(
69
75
  attempts,
70
76
  error,
71
77
  });
72
- if (shouldRetry) {
73
- attempt(attempts + 1);
74
- } else {
78
+ if (!shouldRetry) {
75
79
  observer.error(error);
80
+ return;
81
+ }
82
+ const delayMs = opts.retryDelayMs?.(attempts) ?? 0;
83
+
84
+ if (delayMs <= 0) {
85
+ attempt(attempts + 1);
86
+ return;
76
87
  }
88
+ callNextTimeout = setTimeout(
89
+ () => attempt(attempts + 1),
90
+ delayMs,
91
+ );
77
92
  },
78
93
  next(envelope) {
79
94
  //
@@ -94,6 +109,7 @@ export function retryLink<TInferrable extends InferrableClientTypes>(
94
109
  }
95
110
  return () => {
96
111
  next$.unsubscribe();
112
+ clearTimeout(callNextTimeout);
97
113
  };
98
114
  });
99
115
  };